有很大的可能是eclipse(什麼是Eclipse:java開發應該使用什麼工具 )沒有指定jdk版本(如何安裝Jdk:如何安裝和配置Jdk)路徑,啟動時候加載不到jdk導致的閃退。廢話不多說,直接說解決辦法。
1、打開$ECLIPSE_HOME/Eclipse.app/Contents/MacOS/eclipse.ini文件:
在Finder中右鍵或者Ctrl+點擊Eclipse應用程序,然後點擊"顯示包內容",進入目錄Contents/MacOS/即可找到。-vm /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java系統默認則是:
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java附帶給出查詢JAVA_HOME指向的查詢方法,如下:
/usr/libexec/java_home -V
可以查看所有的JAVA_HOME指向哪:
Matching Java Virtual Machines (4): 1.8.0_40, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home 1.7.0_79, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home 1.6.0_65-b14-468, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
顯示文件信息,如下:
ls -ltr /usr/libexec/java_home
結果:
lrwxr-xr-x 1 root wheel 79 12 30 10:36 /usr/libexec/java_home -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home