2021-05-12 14:32:11
Mac下安裝和管理Java
2020-06-16 18:07:26
Mac OSX 10.9以後系統就自帶了Java 6的環境,路徑在:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
如果想要安裝升級到Java 7的環境,步驟如下:
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
- 2.安裝成功後設定環境變數
在.bash_profile檔案中新增:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
需要說明的是Mac OSX 10.5之後蘋果就建議設定$JAVA_HOME變數到/usr/libexec/java_home
- 3.設定完成後輸入下列命令測試下
$java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
# 檢視系統安裝的java版本
$/usr/libexec/java_home -V
Matching Java Virtual Machines (3):
1.7.0_60, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_60.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
# 返回系統安裝的java最高版本
$/usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
Ubuntu下安裝JDK7(附Clojure下載) http://www.linuxidc.com/Linux/2012-10/71557.htm
Ubuntu 12.04下安裝JDK1.7 http://www.linuxidc.com/Linux/2012-06/62239.htm
Ubuntu 14.04 LTS安裝Oracle JDK 1.8 http://www.linuxidc.com/Linux/2014-11/109216.htm
CentOS6.3安裝JDK和環境設定 http://www.linuxidc.com/Linux/2012-09/70780.htm
Ubuntu 14.04 安裝 JDK8 http://www.linuxidc.com/Linux/2014-09/106218.htm
Ubuntu下安裝JDK圖文解析 http://www.linuxidc.com/Linux/2014-09/107291.htm
相關文章