title: use JNI to start JVM Builder C++
body: <p>in this post <a href="https://stackoverflow.com/questions/25548699/how-to-use-jni-to-start-jvm-in-builder-c-application/25549109?noredirect=1#comment39894205_25549109">How to use JNI to start JVM in builder C++ application</a> i converted jvm.lib from Coff to Omf. i used it to link JNI_CreateJavaVM() function. But it crash .</p>
  
  <p>I used another code to start JVM from Builder C++ application. When i load the jvm.dll. It work!! the JVM is created when i load jvm in java directory but not when i copy this file(jvm.dll) in another directory and call it from this directory.Can you explain why i can't use a copy of jvm.dll to creat my JVM?</p>
  
  <p>This is my Code :</p>
  
  <pre><code>JNIEnv *env;
  JavaVMInitArgs vm_args;
  JavaVMOption options;
  memset(&amp;vm_args, 0, sizeof(vm_args));
  
  options.optionString = "-Djava.class.path=.;tika-app-1.5.jar;";
  jint ii = GetVersion();
  
  vm_args.version = JNI_VERSION_1_6;
  vm_args.nOptions = 1;
  vm_args.options = &amp;options;
  vm_args.ignoreUnrecognized = 0;
  //String strPath = "C:\\Users\\mhechkel\\Documents\\RAD Studio\\Projects\\TestJVM\\Win32\\Debug\\jvm.dll";  
  // when i copy jvm.dll in my application folder: It dosn't work!!!
  String strPath = "C:\\Program Files (x86)\\Java\\jdk1.7.0_65\\jre\\bin\\server\\jvm.dll";
  
  HMODULE jvm_dll = LoadLibrary(strPath.c_str()); //here it work fine!!
  
  /// You might check the GetLastError() here after the LoadLibrary()
  if(jvm_dll == NULL) 
  {    
      Label1-&gt;Caption = "can't load dll"; 
  }
  
   JNI_CreateJavaVM_ptr = (JNI_CreateJavaVM_func)GetProcAddress(jvm_dll, "JNI_CreateJavaVM");
  
   /// You might check the GetLastError() here
   if(JNI_CreateJavaVM_ptr == NULL)
   {
        Label1-&gt;Caption = "can't load function";
   }
  
   int ret = JNI_CreateJavaVM_ptr(jvm, (void**)&amp;env, &amp;vm_args);
   if(ret &lt; 0)
   {
      Label1-&gt;Caption = "Unable to Launch JVM\n";
   }
   return env;
  </code></pre>