由于 Oracle Java 许可,我已从 macOS 10.14.3 中删除了 Java 并安装了 OpenJDK8。
AB-iMac:~ AndyBrunner$ cat .bash_profile
export JAVA_HOME=/Applications/Java/OpenJDK/JDK1.8/Contents/Home/bin/
export PATH=$JAVA_HOME:$PATH
AB-iMac:~ AndyBrunner$ echo $JAVA_HOME
/Applications/Java/OpenJDK/JDK1.8/Contents/Home/bin/
AB-iMac:~ AndyBrunner$ echo $PATH
/Applications/Java/OpenJDK/JDK1.8/Contents/Home/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public
AB-iMac:~ AndyBrunner$ java -version
openjdk version "1.8.0_202"
OpenJDK Runtime Environment (build 1.8.0_202-b08)
Eclipse OpenJ9 VM (build openj9-0.12.1, JRE 1.8.0 Mac OS X amd64-64-Bit Compressed References 20190205_147 (JIT enabled, AOT enabled)
OpenJ9 - 90dd8cb40
OMR - d2f4534b
JCL - d002501a90 based on jdk8u202-b08)
但是当我启动 Eclipse 时,出现错误消息“无法创建 Java 虚拟机”。弹出。
需要什么才能告诉 Eclipse 使用 OpenJDK?
最佳答案
您在 eclipse.ini
中指定要使用的 VM。
On a Mac OS X system, you can find eclipse.ini by right-clicking (or Ctrl+click) on the Eclipse executable in Finder, choose Show Package Contents, and then locate eclipse.ini in the Eclipse folder under Contents. The path is often
/Applications/Eclipse.app/Contents/Eclipse/eclipse.ini For versions of Mac OS X 10.7+ the location is something like /Library/Java/JavaVirtualMachines//Contents/Home/bin
For example, the latest JDK 1.8 (as of July 2015) is /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin
https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Mac_OS_X_Example
所以在你的情况下:
-vm
/Applications/Java/OpenJDK/JDK1.8/Contents/Home/bin/
关于java - macOS Eclipse 找不到 OpenJDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54666906/