Creating Shared library for C++ code
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ashmi_c
Posted On:   Monday, December 2, 2002 10:24 AM

Hello, I want to use JNI to interface with some C++ code. This code does nothing but create a C++ object and call some functions on it. The Java part of the application does NOT know about the C++ object or any C++ specific features. How do I create the shared C++ library (using g++ on solaris 8)? Please suggest the specific command. I include some sample code blocks. thanks, ashmi e.g. Java: public class A { private native void init(); private native void somefn(); private native void destroy(); main() { A a = new A(); a.init(); a.somefn(); a.destroy(); } static { System.loadLibrary(   More>>

Hello,
I want to use JNI to interface with some C++ code. This code does nothing but create a C++ object and call some functions on it. The Java part of the application does NOT know about the C++ object or any C++ specific features.

How do I create the shared C++ library (using g++ on solaris 8)? Please suggest the specific command. I include some sample code blocks.

thanks,
ashmi



e.g. Java:

			
public class A {
private native void init();
private native void somefn();
private native void destroy();

main() {
A a = new A();
a.init();
a.somefn();
a.destroy();
}
static {
System.loadLibrary("cpluspluslib");
}

}




C++ side:
			
// There is some class Handle
Handle *h;
...//JNI method signature for init()
{
h = new Handle;
}

...// JNI method signature for somefn()
{
h->callSomeFunction();
cout < < "called somefunction on h";
}

...//JNI method signature for destroy()
{
delete h;
}


   <<Less
About | Sitemap | Contact