Possible Duplicate:
How to access the Java method in a C++ application
Suppose I have a Java class like this :
class MyClass
{
String value = "a string value";
String getValue()
{
return value;
}
}
I've been trying for hours to implement a JNI function that calls a Java function and returns a string. Could someone show me through a snippet how to call the "getValue" function from a C++ using JNI and obtain a jstring variable with the value of String variable from "MyClass.
// C++
jobject result;
jMethodID method_getValue = m_env->GetMethodID(native_object,"getValue","()Ljava/lang/String;");
result = m_env->CallObjectMethod(native_object, method_getValue);