mac上切换jdk版本
在~/.profile中增加如下内容
alias setJdk6='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)'
alias setJdk7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
alias setJdk8='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)'
切换java_home为1.6版本
setJdk6
切换java_home为1.7版本
setJdk7
切换java_home为1.8版本
setJdk8
JDK的安装路径
jdk 1.6 /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
jdk 1.7 /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/
jdk 1.8 /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/
bin位置:Contents/Home/bin/
参考网址
http://support.apple.com/en-us/HT202643
http://hints.macworld.com/article.php?story=20121024002012496
https://wimdeblauwe.wordpress.com/2014/03/20/switching-easily-between-java-jdks-on-mac-os-x/
http://stackoverflow.com/questions/17885494/how-can-i-change-mac-oss-default-java-vm-returned-from-usr-libexec-java-home