右键单击 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>
-->
请注意注释掉的部分。将 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>
-->
最后一步,浏览到 /Library/Java/JavaVirtualMachines 并检查其中的 jdk 包名称。将上述命令中的 jdk 版本替换为该版本。
/Library/Java/JavaVirtualMachines/{your_jdk_package_name}/Contents/Home/bin/java
可选:在某些计算机上,您可能需要在完成所有这些操作后关闭查找器,导航到 eclipse 文件夹并再次单击 eclipse 才能使其正常工作。