Freewind @ Thoughtworks scala java javascript dart 工具 编程实践 月结 math python english [comments admin] [feed]

(2014-04-26) 不要删你mac上的jdk1.6

广告: 云梯:翻墙vpn (省10元) 土行孙:科研用户翻墙http proxy (有优惠)

今天早上打开电脑,发现Idea启动不了了!Eclipse也启动不了!

经过两个多小时的修复,终于找到了原因:我昨天升级jdk后,把Mac自带的jdk1.6删了,而Idea它们就找不到了。

虽然我已经把/usr/bin/java设成了最新的java路径,后来还在~/.profile~/.zshrc里都设置了:

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
export JDK_HOME=`/usr/libexec/java_home -v 1.7`

还是不行。

经过搜索,在https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under里找到了一段话:

Mac OS X

At the moment all our products require Apple JDK 1.6 to be installed in order to run on Mac. JDK 1.7 from Oracle is not officially supported yet and has known problems that stop us from using it by default. Oracle JDK 1.7.0_40 has added support for Retina and works much better than previous versions on Mac. You are welcome to give it a try in case you have any problems with Apple JDK.

To force running under JDK 1.7 edit /Applications/.app/Contents/Info.plist file, change JVMVersion from 1.6 to 1.7 :

<key>JVMVersion</key>
<string>1.7*</string>

似乎IDEA在mac上,默认情况只支持jdk1.6,除非把JVMVersion的值改成1.7*。我改了以后,的确可以启动了,但是也不能每个程序都这么改吧。

于是只好重装jdk1.6。在java的官网上,还找不到mac里1.6的安装包,最后在这里找到了:

http://support.apple.com/kb/DL1573

安装好以后,idea/eclipse就可以正常启动了。

jdk路径

Mac里jdk安装的路径还会变,比如曾经jdk1.6,会安装在:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk

而jdk1.7和1.8,就会安装在:

/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk

而且好像一般的java程序还只认第一个。所以为了减少麻烦,最好不要删除你mac上的jdk1.6

comments powered by Disqus