简体   繁体   中英

Java. JNI. jvm.dll

I have Visual Studio C++ Project, which has to call some java functionality. I'm going to use JNI. I have specified additional include directories:

C:\\Program Files (x86)\\Java\\jdk1.7.0_10\\include

C:\\Program Files (x86)\\Java\\jdk1.7.0_10\\include\\win32

and additional library directory

C:\\Program Files (x86)\\Java\\jdk1.7.0_10\\lib

and was able to compile needed code. But I still cannot run it because of the next error:

The program can't start bacause jvm.dll is missing...

I assume, the simplest way is just to copy the dll into the project directory. But I don't know which one. I found, for example, few different of them:

C:\\Program Files (x86)\\Java\\jdk1.7.0_10\\jre\\bin\\client\\jvm.dll

C:\\Program Files (x86)\\Java\\jdk1.7.0_10\\jre\\bin\\server\\jvm.dll

C:\\Program Files (x86)\\Java\\jre7\\bin\\client\\jvm.dll

So, which one should I copy?

You are trying to solve the problem at the wrong end. You are not expected to be copying jvm.dll around, but to set a proper JAVA_HOME environment variable, pointing to either C:\\Program Files (x86)\\Java\\jdk1.7.0_10\\ or C:\\Program Files (x86)\\Java\\jre7\\ . The version of DLL is then selected by java parameter -client or -server (default when no parameter).

Update : now re-reading the question, i see that the scenario is running native program and invoke JVM from it, not (more common) invoking native lib from JVM. In that case, the native program really needs access to jvm.dll . When invoking native lib from JVM, jvm.dll is already preloaded by JVM and the native lib doesn't need to care about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM