安裝<br />因為並非所有使用者都用得著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/VirtualMachines/jdk1. 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.k/Contents/Home1.6.0_65-b14-462, x506464 " /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home1.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 ~/.profileJAVA_HOME=`/usr/libexec/java_home`export JAVA_HOME$ echo $JAVA_HOME/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home$ source ~/.profile $source ~/.profile $source