编辑 $ECLIPSE_HOME/Eclipse.app/Contents/MacOS/eclipse.ini 文件,在 Finder 中右键或者Ctrl+点击 Eclipse 应用程序,然后点击“显示包内容”,进入目录 Contents/MacOS/ 即可找到
通过 ls -ltr /Library/Java/JavaVirtualMachines/ 列出已经安装好的各个 JDK 版本的路径,然后在 eclipse.ini 文件中指定之,比如:
-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java
系统默认则是
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
同时,可以先通过执行 /usr/libexec/java_home -V 可以查看所有的 JAVA_HOME 指向哪,比如:
Matching Java Virtual Machines (5):
1.8.0_25, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
1.8.0_20, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
1.7.0_71, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-466.1, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
ls -ltr /usr/libexec/java_home 显示文件信息