Install Java (jre-7u60) on Mac OS X Mountain Lion via CLI

We get the following message when using Java Web Start (javaws) on Mac:

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

System Information

We’re using 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

Install Java SE Runtime Environment 7

We will be installing JRE 7 Update 60 Build b02 Early Access Release.

Install all recommended updates:

# softwareupdate -ir

Download 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

Mount the .dmg disk image:

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

Install Java package:

# 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.

Unmount the disk:

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

Check Java version:

# 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)