Actualy I want to use a DLL which is comprising of C++ classes. I am to call two methods defined in a C++ class like:
class CPPClass {
void function1(char* s1, char* s2 );
void function2(float* f );
}
I am to call these two methods from a java class. First I will have to create the instance of the class then call the functions. How can i do this?
And I'm telling you that you cannot directly do that.
The interface between a DLL and the world outside it is C, not C++.
A posible way to handle this is to write a - C - initialization routine. Have that initialization routine called by something in your java.
What the initialization routine does is instantiate the classes you want to use, and leave pointers in global memory.
Now when you want to call methods on those objects, you call - C - functions that use the object pointers to call the correct methods on those objects.
Yes! I have understand it.
Now I am reached to this link http://www.javaworld.com/javaworld/javatips/jw-javatip17.html?page=2
void NumberListProxy_initCppSide(struct HNumberListProxy* Obj);
the method signature is different from the one that is generated here at my machine by java which is:
JNIEXPORT void JNICALL Java_NumberListProxy_initCppSide
(JNIEnv *, jobject);
Also when I run the command ' javah stubs NumberListProxy '
Error: JNI does not require stubs, please refer to the JNI documentation.
I think u ( bschauwejava ) can tell me about this problem.