java 无法加载 JVM
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15873213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot load JVM
提问by atoMerz
I'm trying to run java code from C using code taken from here. The code that attempts to run JVM is as follows:
我正在尝试使用从这里获取的代码从 C 运行 java 代码。尝试运行JVM的代码如下:
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options;
options.optionString = "-Djava.class.path=D:\Java Src\TestStruct";
vm_args.version = JNI_VERSION_1_6;
vm_args.nOptions = 1;
vm_args.options = &options;
vm_args.ignoreUnrecognized = 0;
int ret = JNI_CreateJavaVM(jvm, (void**)&env, &vm_args);
The code compiles fine however, when I try to execute it I get the following error:
代码编译得很好,但是,当我尝试执行它时,出现以下错误:
Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries
虚拟机初始化时出错无法加载本机库:找不到依赖库
Looking at thisquestion I used dependency walker to find out which binaries I'm missing. It turns out I'm missing ieshims.dll
and wer.dll
from my computer which according to thisthe mentioned dlls are used in vista and above (I'm on XP).
So several questions come to my mind:
看着这个问题,我使用了dependency walker 来找出我遗漏了哪些二进制文件。事实证明,我的思念ieshims.dll
,并wer.dll
从我的电脑,其根据本所提到的DLL在Vista及以上的(我在XP)被使用。
所以我想到了几个问题:
- How do I get rid of this?
- Why am I getting this error in the first place? Can't I load JVM in XP?
- 我该如何摆脱这个?
- 为什么我首先会收到此错误?我不能在 XP 中加载 JVM 吗?
I'm on Windows XP, using Visual Studio 2008, JDK 1.7 installed (tried with 1.6 too).
我在 Windows XP 上,使用 Visual Studio 2008,安装了 JDK 1.7(也尝试过 1.6)。
回答by Roger Rowland
There's a similar question in the discussion thread below the article that you linked.
您链接的文章下方的讨论主题中有一个类似的问题。
In there, a user found that the solution is to make sure you have the path to your Java binaries in the PATH
environment variable. For example:
在那里,用户发现解决方案是确保您在PATH
环境变量中拥有 Java 二进制文件的路径。例如:
PATH = "C:\Program Files\Java\jdk1.6.0_18\jre\bin\client";...
回答by Artur Witek
There's another way - you can load dynamically jvm.dll from a custom location and set java.library.path variable pointing to the native libs. This way it will not have to depend on system env PATH.
还有另一种方法 - 您可以从自定义位置动态加载 jvm.dll 并设置指向本机库的 java.library.path 变量。这样它就不必依赖于系统环境 PATH。
Here's example in other thread:
这是其他线程中的示例: