Using static linking
- 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. - Set the
PATH
environement variable to start with the folder of a JREjvm.dll
. And don't use the"c:\folder with space in name"
notation (that is surrounding the path withdouble quotes
). Just useset path=c:\folder with space in name;%PATH%
. That mistake made my previous attempts worthless.
Using dynamic linking.
- 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. - Drop
jvm.lib
from your project configuration - Use
LoadLibrary
, with the full path for jvm.dll (escape '\' or use '/') - Use
GetProcAddress
for "JNI_CreateJavaVM
" - Make sure to use a proper
typedef
for the function pointer (useJNICALL
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
)