Hi Guys,
I have an urgent question to ask for help. I am planning to write some Java objects as the wrappers for some C++ objects. For
example:
I have C++ objects:
class A
{
public: void print( )
{
printf("%s\n", "Hello World !");
}
};
class B
{
public: A* get_instance( )
{
return new A( );
}
};
and I have Java classes as the wrappers:
public class JA
{
public native void print();
static
{
System.loadLibrary("ABshared");
}
}
public class JB
{
public native JA get_instance();
static
{
System.loadLibrary("ABshared");
}
}
but how can I implement my native methods in C++ so that JA and JB can hold pointers to A and B respectively ?
JNIEXPORT void JNICALL Java_JA_print
(JNIEnv *env, jobject obj)
{
//implement me
}
JNIEXPORT jobject JNICALL Java_JB_get_1instance
(JNIEnv *env, jobject obj)
{
//implement me
}
thank you very much !