I got a problem with "CallIntMethod". I try to use a java method to pass a number to a C++ method,and print it in that C++ method. But i let java pass something like 1,2,3.. the C++ method only print '0'.
/* my java code: */
public class returnInt{
public int reInt(){
int i = 3;
return i;
}
}
/* my C++ code*/
.......
/* Get the "returnInt" class. */
java_class = env->FindClass("returnInt");
if (java_class == NULL) {
cout << "error finding 'Foo' class\n" << endl;
}
/* Get the "enterInt" method ID. */
method_id = env -> GetMethodID(
java_class,
"reInt",
"()I"
);
if (method_id == NULL) {
cout << "error finding 'reInt' method\n" << endl;
}
/* Call returnInt::reInt . */
int javaint;
javaint = env -> CallIntMethod(
java_class,
method_id,
NULL /* args */
);
/* print javaint */
cout << javaint << endl;
...............
I think there must be some mistakes in my code..
How to use the "CallIntMethod"?