title: env->FindClass("java.lang.Math");
body: <p><code>env-&gt;FindClass("java.lang.Math");</code> fails. Why?</p>
  
  <pre><code>gcc -I/System/Library/Frameworks/JavaVM.framework/Headers test.cpp -framework JavaVM -o test &amp;&amp; ./test
  </code></pre>
  
  <p><a href="http://developer.apple.com/library/mac/#samplecode/simpleJavaLauncher/Listings/utils_h.html#//apple_ref/doc/uid/DTS10000688-utils_h-DontLinkElementID_7" rel="nofollow">http://developer.apple.com/library/mac/#samplecode/simpleJavaLauncher/Listings/utils_h.html#//apple_ref/doc/uid/DTS10000688-utils_h-DontLinkElementID_7</a>
  http://developer.apple.com/library/mac/#technotes/tn2147/_index.html</p>
  
  <pre><code>#include &lt;jni.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main() {
      printf("START.\n");
  
      JavaVM* jvm = NULL;
      JNIEnv *env;
  
      JavaVMInitArgs vm_args;
      JNI_GetDefaultJavaVMInitArgs(&amp;vm_args); 
      vm_args.version = JNI_VERSION_1_6;
      vm_args.nOptions = 0;
  
      int ret = JNI_CreateJavaVM(&amp;jvm, (void**)&amp;env, &amp;vm_args);
      if(ret &lt; 0) {
          printf("Unable to Launch JVM\n");       
      return 1;
      }
  
      jclass mathClass = env-&gt;FindClass("java.lang.Math"); 
      if (mathClass == NULL) {
          printf("Unable to find java.lang.Math\n");
      return 1;
      }
  
      jmethodID cosMethod = env-&gt;GetStaticMethodID(mathClass, "cos", "(D)D");
      if (cosMethod == NULL) {
          printf("Unable to find java.lang.Math.cos()\n");
      return 1;
      }
  
      printf("call\n");
      jdouble jIn = 0.1;
      jdouble jOut = env-&gt;CallStaticIntMethod(mathClass, cosMethod, jIn);
      printf("jOut: %f", jOut);
  
      printf("DestroyJavaVM.\n");
      jvm-&gt;DestroyJavaVM(); 
      printf("END.\n");
  
      return 0;
  }
  </code></pre>