title: Calling a java function from C++ via JNI that returns a string
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/992836/how-to-access-the-java-method-in-a-c-application">How to access the Java method in a C++ application</a>  </p>
  </blockquote>
  
  
  
  <p>Suppose I have a Java class like this :</p>
  
  <pre><code>class MyClass
  {
    String value = "a string value";
  
    String getValue()
    {
      return value;
    }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>// C++</p>
  
  <pre><code>jobject result;
  
  jMethodID method_getValue = m_env-&gt;GetMethodID(native_object,"getValue","()Ljava/lang/String;");
  
  result = m_env-&gt;CallObjectMethod(native_object, method_getValue);
  </code></pre>