I\'m trying to call a Java method from C++ using JNI. To do that I\'ve installed jdk1.7.0_51
, linking against jdk1.7.0_51\\lib\\jvm.lib
, including
Using static linking
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.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.
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.jvm.lib
from your project configurationLoadLibrary
, with the full path for jvm.dll (escape '\' or use '/')GetProcAddress
for "JNI_CreateJavaVM
"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
)