Why my "CallIntMethod" always return 0

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: */

publicclass returnInt{

publicint 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"?

[1759 byte] By [Taurenla] at [2007-10-3 0:50:09]
# 1

You are calling the method on the class, rather than an instance of an object. Either change the java method so that it is static, or supply a reference to an instance of returnInt.

(By the way: the convention is that java class names begin with a cpaital letter, thus:

class ReturnInt { ....

bschauwejavaa at 2007-7-14 17:45:15 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Thank you, very much ,espacially your "By the way": )I will try. And I will care the convention.
Taurenla at 2007-7-14 17:45:15 > top of Java-index,Java HotSpot Virtual Machine,Specifications...