mac 并存多版本java



The java, javac, etc. command line tools are sensitive to the value of the JAVA_HOME environment variable and will use 1.6 if this variable points to a 1.6 JDK.

The tool /usr/libexec/java_home is your friend here. Running

/usr/libexec/java_home

will print out the appropriate JAVA_HOME value for the most up to date JDK on your system. 

you can apply constraints using the -v flag, for example

/usr/libexec/java_home -v '1.6*'

will return a JAVA_HOME value for the best available 1.6 JDK on your system. You can use this value to set JAVA_HOME:

export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`

either as a one-off for a particular Terminal session, or permanently for all future terminal sessions by adding the above line to the .bash_profile file in your home directory.


$ export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`
$ java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
$ export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`

$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
参考链接: http://stackoverflow.com/questions/13594864/how-to-revert-to-java-1-6-on-mac-os-x-10-7-5
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值