码迷,mamicode.com
首页 > 编程语言 > 详细

在MAC上查找和设置$JAVA_HOME

时间:2015-03-13 18:53:00      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:mac   java   java-home   

可以使用工具命令“/usr/libexec/java_home”来定位JAVA_HOME:

定位JAVA:

/usr/libexec/java_home -V
Matching Java Virtual Machines (1):
    1.8.0_25, x86_64:   "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

另外可以使用-V选项列出所有版本的JAVA_HOME:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    1.7.0_45, x86_64:   "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
    1.6.0_65-b14-462, x86_64:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-462, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home

配置JAVA_HOME:

$ cat ~/.profile

JAVA_HOME=`/usr/libexec/java_home`
export JAVA_HOME

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
$ source ~/.profile 
$java

在MAC上查找和设置$JAVA_HOME

标签:mac   java   java-home   

原文地址:http://blog.csdn.net/caiwenfeng_for_23/article/details/44243083

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!