Search This Blog

Thursday, March 17, 2011

JNI and C++ FindClass method

JNI is a great way to use java class in your c++ code, in case you really need it, a good article with full sample could be found in the next topic.
How to Call Java Functions from C Using JNI - CodeProject
when consuming a class in jar file dont forget to:
supply the jar file in the option:
-Djava.class.path=D:\myJar.jar

and when you need to use the FindClass methos supply the full path:
jclass myClass = env->FindClass("mm/test/HelloWorld");

when you need a pointer to the method id , use full path to the parameter as well , in case you need it:
in java its define such:
public static WorkOrder2 ChangeTheObj(WorkOrder2 obj);
in your c++:
jmethodID myMethod = env->GetStaticMethodID(clsH,"ChangeTheObj","(Lmm/test/WorkOrder2;)Lmm/test/WorkOrder2;");
Yaniv Tzanany

No comments: