title: Calling a JAVA method from C++ with JNI, no parameters
body: <p>Please bear with me, I am an iPhone developer and this whole android this confuses me a bit. </p>
  
  <p>I have some c++ methods that are called from a cocos2d-x CCMenuItem. Therefore I cannot send any parameters, according to the docs. </p>
  
  <p>I need to open a url with the android browser which will require me to call a JAVA function to start a new intent.</p>
  
  <p>I understand that I need to create a VM, however the below code gives me the error: </p>
  
  <blockquote>
    <p>jni/../../Classes/OptionsScene.cpp:184: error: 'JNI_CreateJavaVM' was
    not declared in this scope</p>
  </blockquote>
  
  <p>I was looking at this thread: <a href="https://stackoverflow.com/questions/5198105/calling-a-java-method-from-c-in-android">Calling a java method from c++ in Android</a></p>
  
  <p>But he uses parameters, and I can't do that. And I don't see where those are in his code to just make them myself.</p>
  
  <p>I don't know what the string should be in the 'Find Class' method.
  Also, I assume it is pretty terrible to create a new VM instance in every method I need to call. How would I create one as a singleton to use across the board? </p>
  
  <p>This is my c++ code called by my menu item:</p>
  
  <pre><code>#include &lt;jni.h&gt;
  ...
  JavaVM *vm; // Global
  ...
  void OptionsScene::website(){
  JNIEnv *env;
  JavaVMInitArgs vm_args;
  vm_args.version = JNI_VERSION_1_2;
  vm_args.nOptions = 0;
  vm_args.ignoreUnrecognized = 1;
  
  jint result = JNI_CreateJavaVM(&amp;vm, (void **)&amp;env, &amp;vm_args); // This line still errors
  
  jclass clazz = env-&gt;FindClass("com/prndl/project/WebExecute");
  jmethodID method = env-&gt;GetMethodID(clazz, "website", "(Ljava/lang/String;)V");
  env-&gt;CallVoidMethod(NULL,method);
  
  vm-&gt;DestroyJavaVM();
  </code></pre>
  
  <p>And this is the JAVA Method that I need to call:</p>
  
  <pre><code>public class WebExecute extends Activity{
      public void website(){
          Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
          startActivity(browserIntent);
      }
  }
  </code></pre>
  
  <p>Honestly, I am struggling with this, any help is appreciated. Thanks.</p>