JNI_CreateJavaVM() terminates with exit code 1

三世轮回 提交于 2019-11-29 13:46:06

Using static linking

  1. remove the jvm.dll from your project directories. The dll must be loaded from it's original location, as it seems that other DLLs are involved, found by references.
  2. Set the PATH environement variable to start with the folder of a JRE jvm.dll. And don't use the "c:\folder with space in name" notation (that is surrounding the path with double quotes). Just use set path=c:\folder with space in name;%PATH%. That mistake made my previous attempts worthless.

Using dynamic linking.

  1. remove the jvm.dll from your project directories. The dll must be loaded from it's original location, as it seems that other DLLs are involved, found by references.
  2. Drop jvm.lib from your project configuration
  3. Use LoadLibrary, with the full path for jvm.dll (escape '\' or use '/')
  4. Use GetProcAddress for "JNI_CreateJavaVM"
  5. Make sure to use a proper typedef for the function pointer (use JNICALL as calling convention)

Patching your code with above steps makes my VS2012/Seven64/x86Debug/JDK1.6 project to output "This code is never reached" (with ret == JNI_OK)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!