安装
因为并非所有用户都用得着 java ,所以在默认状态下 os x 不预装 java , 如果你需要的话可以手动安装.
1. http://support.apple.com/kb/dl1572
到苹果官网下载.
http://support.apple.com/downloads/dl1572/en_us/javaforosx2014-001.dmg
2.http://www.oracle.com/technetwor ... ownloads/index.html
到 oracle 下载最新版的 java 8 jdk 安装.
安装后在终端输入
java -version
如果显示版本就说明安装好了.
如果显示如下, 就说明没安装对,需要重新来过.
no java runtime present, requesting install.
在mac上查找和设置$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
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!