title: JNI Call java method from c program
body: <p>I need to call java method from c program. i have tried below code to call the java method through Java native interface but facing issues while compilation. i m new to C and have experience in java. so, i m not able to think myself what is happening while creating JVM.</p>
  
  <p>Below is the code.</p>
  
  <pre><code>CTest.c
  #include &lt;stdio.h&gt;
  #include &lt;jni.h&gt;
  
  JNIEnv* create_vm() {
      JavaVM* jvm;
      JNIEnv* env;
      JavaVMInitArgs args;
      JavaVMOption options[1];
      args.version = JNI_VERSION_1_6;
      args.nOptions = 1;
      options[0].optionString = "-Djava.class.path=D:\\Ashish_Review\\JNI\\src";
      args.options = options;
      args.ignoreUnrecognized = JNI_FALSE;
  
      JNI_CreateJavaVM(&amp;jvm, (void **)&amp;env, &amp;args);
      return env;
  }
  
  void invoke_class(JNIEnv* env) {
      jclass helloWorldClass;
      jmethodID mainMethod;
      jobjectArray applicationArgs;
      jstring applicationArg0;
  
      helloWorldClass = (*env)-&gt;FindClass(env, "HelloWorld");
  
      mainMethod = (*env)-&gt;GetStaticMethodID(env, helloWorldClass, "main", "([Ljava/lang/String;)V");
  
      applicationArgs = (*env)-&gt;NewObjectArray(env, 1, (*env)-&gt;FindClass(env, "java/lang/String"), NULL);
      applicationArg0 = (*env)-&gt;NewStringUTF(env, "From-C-program");
      (*env)-&gt;SetObjectArrayElement(env, applicationArgs, 0, applicationArg0);
  
      (*env)-&gt;CallStaticVoidMethod(env, helloWorldClass, mainMethod, applicationArgs);
  }
  
  
  int main(int argc, char **argv) {
      JNIEnv* env = create_vm();
      invoke_class( env );
  }
  
  
  C:\Users\Desktop\tcc&gt;tcc C:\TurboC++\Disk\TurboC3\BIN\CTest.c -I "C:\Program Files\Java\jdk1.6.0_16\include" -I "C:\Program Files\Java\jdk1.6.0_16\include\win32" -shared -o CTest.dll
  tcc: undefined symbol '_JNI_CreateJavaVM@12'
  </code></pre>
  
  <p>please help me out.</p>