Mac OS、JDK1.7(和 1.8)不包含 JNI_CreateJavaVM 符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24589932/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 13:16:09  来源:igfitidea点击:

Mac OS, JDK1.7 (and 1.8) does not contain the JNI_CreateJavaVM symbol

javaeclipsemacos

提问by Andrea Sindico

I need to run Eclipse Kepler on Mac OS through a JDK 1.7 (This is required by the PyDev plugin).

我需要通过 JDK 1.7 在 Mac OS 上运行 Eclipse Kepler(这是 PyDev 插件所必需的)。

The problem is that although I have managed to install the 1.7 jdk and configured the eclipse.ini to use it I get the error

问题是,虽然我已经设法安装了 1.7 jdk 并配置了 eclipse.ini 来使用它,但我得到了错误

The JVM shared library "/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin../jre/lib/server/libjvm.dylib" does not contain the JNI_CreateJavaVM symbol.

JVM 共享库“/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin../jre/lib/server/libjvm.dylib”不包含 JNI_CreateJavaVM 符号。

UPDATEsmart people here https://github.com/joeferner/node-java/issues/90claim it is enough to add JNI to the JVMCapabilities in the info.plist file like

在这里更新聪明的人https://github.com/joeferner/node-java/issues/90声称将 JNI 添加到 info.plist 文件中的 JVMCapabilities 就足够了,例如

<key>JVMCapabilities</key>
   <string>JNI</string>

But I tried it and it does not work in my case

但我试过了,在我的情况下不起作用

采纳答案by Shan

Right click on the Eclipse icon and select 'show package contents'. Inside the contents directory you'll find a file called 'Info.plist'. Scroll down to the bottom of the file till you find this

右键单击 Eclipse 图标并选择“显示包内容”。在内容目录中,您会找到一个名为“Info.plist”的文件。向下滚动到文件底部,直到找到这个

<key>Eclipse</key>
    <array>
        <!-- to use a specific Java version (instead of the platform's default) uncomment one of the following options,
                or add a VM found via $/usr/libexec/java_home -V
          <string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java</string>
          <string>-vm</string><string>/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Commands/java</string>
        -->

Notice the commented out section. Move the jdk path declaration out of the comments section. It should look like this now.

注意注释掉的部分。将 jdk 路径声明移出注释部分。现在应该是这个样子。

<key>Eclipse</key>
    <array>
      <string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java</string>
        <!-- to use a specific Java version (instead of the platform's default) uncomment one of the following options,
                or add a VM found via $/usr/libexec/java_home -V
          <string>-vm</string><string>/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Commands/java</string>
        -->

Last step, browse to /Library/Java/JavaVirtualMachines and check the jdk package name present there. Replace the jdk version in the above command with that.

最后一步,浏览到 /Library/Java/JavaVirtualMachines 并检查那里的 jdk 包名称。用那个替换上面命令中的 jdk 版本。

/Library/Java/JavaVirtualMachines/{your_jdk_package_name}/Contents/Home/bin/java

Optional: On some machines you may have to close the finder after you've done all this, navigate to the eclipse folder and click on eclipse again for it to work.

可选:在某些机器上,您可能需要在完成所有这些操作后关闭 finder,导航到 eclipse 文件夹并再次单击 eclipse 以使其工作。

回答by tobylaroni

Just for those who may have been stuck after doing both tasks described above and still seeing the same error message: I was certain that I had downloaded 64-bit Eclipse, but it turns out I had the 32-bit version. After downloading 64-bit, everything worked!

仅适用于在执行上述两项任务后可能卡住并仍然看到相同错误消息的人:我确定我已经下载了 64 位 Eclipse,但事实证明我有 32 位版本。下载 64 位后,一切正常!

回答by aalosious

I had a perfectly working Eclipse Luna, and started getting this error while trying to upgrade to Java 8 (and updating jre, jdk etc). Shan's solution didn't work for me. So I just downloaded and installed latest Eclipse. It's working fine. Saves the time of debugging and fiddling around.

我有一个完美运行的 Eclipse Luna,并在尝试升级到 Java 8(并更新 jre、jdk 等)时开始出现此错误。Shan 的解决方案对我不起作用。所以我刚刚下载并安装了最新的 Eclipse。它工作正常。节省调试和摆弄的时间。