最近需要在MAC上做一些测试,由于测试机没有安装Java,只能自己安装,由于不能通过图形化界面访问测试机,只能通过命令行的形式来安装JAVA。
1. Download the jre/jdk install package from Oracle website,use hdiutil to mount the dmg file
sh-3.2# hdiutil mount jre-7u55-macosx-x64.dmg
Checksumming Protective Master Boot Record (MBR : 0)?
Protective Master Boot Record (MBR :: verified CRC32 $A63E199D
Checksumming GPT Header (Primary GPT Header : 1)?
GPT Header (Primary GPT Header : 1): verified CRC32 $12939AC9
Checksumming GPT Partition Data (Primary GPT Table : 2)?
GPT Partition Data (Primary GPT Tabl: verified CRC32 $7832AB48
Checksumming (Apple_Free : 3)?
(Apple_Free : 3): verified CRC32 $00000000
Checksumming disk image (Apple_HFS : 4)?
.................................................................................................................................................................................
disk image (Apple_HFS : 4): verified CRC32 $7C0741DD
Checksumming (Apple_Free : 5)?
(Apple_Free : 5): verified CRC32 $00000000
Checksumming GPT Partition Data (Backup GPT Table : 6)?
GPT Partition Data (Backup GPT Table: verified CRC32 $7832AB48
Checksumming GPT Header (Backup GPT Header : 7)?
GPT Header (Backup GPT Header : 7): verified CRC32 $8D5EC567
verified CRC32 $6A86DC11
/dev/disk2 GUID_partition_scheme
/dev/disk2s1 Apple_HFS /Volumes/Java 7 Update 55
2. Install the jre package
sh-3.2# installer -pkg ‘/Volumes/Java 7 Update 55/Java 7 Update 55.pkg‘ -target /
installer: Package name is Java 7 Update 55
installer: Installing at base path /
installer: The install was successful.
3. Use the following command to check java home
/usr/libexec/java_home
4. Set java home if necessary
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
Install and set JAVA home on MAC OS with commandline,布布扣,bubuko.com
Install and set JAVA home on MAC OS with commandline
原文:http://www.cnblogs.com/spandon/p/3818587.html