1. 程式人生 > >Mac命令列方式升級安裝JDK

Mac命令列方式升級安裝JDK

命令列方式安裝步驟如下:

1. 下載dmg安裝包

下載URL:

2. 安裝前環境檢查     

java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

3. 安裝

3.1  掛載dmg映象

yyj-Mac Downloads$ hdiutil attach jdk-7u80-macosx-x64.dmg 
正在檢查“Protective Master Boot Record (MBR : 0)”的校驗和…
Protective Master Boot Record (MBR ::已驗證   CRC32 $A63E199D
正在檢查“GPT Header (Primary GPT Header : 1)”的校驗和…
 GPT Header (Primary GPT Header : 1):已驗證   CRC32 $DAF7B809
正在檢查“GPT Partition Data (Primary GPT Table : 2)”的校驗和…
GPT Partition Data (Primary GPT Tabl:已驗證   CRC32 $035A270F
正在檢查“ (Apple_Free : 3)”的校驗和…
                    (Apple_Free : 3):已驗證   CRC32 $00000000
正在檢查“disk image (Apple_HFS : 4)”的校驗和…
...............................................................................................................................................................................
          disk image (Apple_HFS : 4):已驗證   CRC32 $775B02CA
正在檢查“ (Apple_Free : 5)”的校驗和…
                    (Apple_Free : 5):已驗證   CRC32 $00000000
正在檢查“GPT Partition Data (Backup GPT Table : 6)”的校驗和…
GPT Partition Data (Backup GPT Table:已驗證   CRC32 $035A270F
正在檢查“GPT Header (Backup GPT Header : 7)”的校驗和…
  GPT Header (Backup GPT Header : 7):已驗證   CRC32 $453AE7A7
已驗證   CRC32 $51FE5723
/dev/disk3          	GUID_partition_scheme          	
/dev/disk3s1        	Apple_HFS                      	/Volumes/JDK 7 Update 80

3.2. 進入解壓後pkg目錄

yyj-Mac Downloads$cd /Volumes/JDK\ 7\ Update\ 80/

3.3.  安裝

yyj-Mac JDK 7 Update 80$ sudo installer -pkg JDK\ 7\ Update\ 80.pkg -target LocalSystem
installer: Package name is JDK 7 Update 80
installer: Installing at base path /
installer: The install was successful.

3.4.  修改環境變數

vi ~/.bash_profile

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home

4.驗證

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
--END