Saturday, May 19, 2001 09:33 AM
Returning an int from a native method is almost the same thing as returning nothing. What I mean is, that primitive return types are easy in JNI. You simply use the JNI primitive type that corresponds with your Java type.
In the case of a Java
int, you have to use
Your method might look like this:
JNIEXPORT jint JNICALL Java_myPackage_myClass_myMethod( JNIEnv * _env, jobject _this )
jint result = 5;
That's all. If you are interested in doing more exciting things with object references, you should look at our tool called JunC++ion. It allows you to implement native methods in C++, without having to worry about JNI at all. You can find out more about it at http://www.codemesh.com. We are currently not available on the Mac, but we're customer-driven, so if there are enough requests for it, we will port it.