通过CLI在Mac OS X Mountain Lion上安装Java(jre-7u60)

时间:2020-03-21 11:48:16  来源:igfitidea点击:

在Mac上使用Java Web Start(javaws)时,我们收到以下消息:

No Java runtime present, requesting install.
Unable to locate a Java Runtime to invoke.

系统信息

我们正在使用Mountain Lion:

# sw_vers
ProductName: Mac OS X
ProductVersion: 10.8.5
BuildVersion: 12F45
# system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: OS X 10.8.5 (12F45)
Kernel Version: Darwin 12.5.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name: MacMini
User Name: System Administrator (root)
Secure Virtual Memory: Enabled
Time since boot: 48 days 23:37

安装Java SE Runtime Environment 7

我们将安装JRE 7 Update 60 Build b02抢先体验版。

安装所有建议的更新:

# softwareupdate -ir

下载Java SE Runtime Environment 7:

# cd ~
# curl -O http://download.java.net/jdk7u60/archive/b02/binaries/jre-7u60-ea-bin-b02-macosx-x86_64-18_dec_2013.dmg?q=download/jdk7u60/archive/b02/binaries/jre-7u60-ea-bin-b02-macosx-x86_64-18_dec_2013.dmg

挂载.dmg磁盘镜像:

# mkdir /mnt
# hdiutil attach -mountpoint /mnt jre-7u60-ea-bin-b02-macosx-x86_64-18_dec_2013.dmg

安装Java软件包:

# installer -pkg /mnt/Java\ 7\ Update\ 60.pkg -target /
installer: Package name is Java 7 Update 60
installer: Upgrading at base path /
installer: The upgrade was successful.

卸载磁盘:

# hdiutil detach /mnt
"disk1" unmounted.
"disk1" ejected.

检查Java版本:

# java -version
java version "1.7.0_60-ea"
Java(TM) SE Runtime Environment (build 1.7.0_60-ea-b02)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b04, mixed mode)