Archive

Archive for June 24, 2013

Installing Apple’s updated Java for OS X 2013-004 and Java for Mac OS X 10.6 Update 16 over previous versions

June 24, 2013 Leave a comment

As part of dealing with the issues caused by the initial versions of Apple’s Java for OS X 2013-004 and Java for Mac OS X 10.6 Update 16, Apple has recommended installing the revised version of the updates overtop of the existing update in order to replace the problematic Java builds.

The fixed Java builds are the following:

Mac OS X 10.6.x: 1.6.0_51-b11-456-10M4509 (currently installed by Java for Mac OS X 10.6 Update 16)

Mac OS X 10.7.x – Mac OS X 10.8.x: 1.6.0_51-b11-457-11M4509 (currently installed by Java for OS X 2013-004)

If you’ve already installed Java for Mac OS X 10.6 Update 16, it appears that there’s no way to use the softwareupdate tool to install it again. For 10.6.x Macs that had previously installed Java for Mac OS X 10.6 Update 16 and got the problematic build, the installer will need to be downloaded from Apple and then installed on your 10.6.x Mac.

For 10.7.x and 10.8.x however, there’s a way to override the install check that softwareupdate uses which is specific to Apple’s Java updates. By setting the JAVA_INSTALL_ON_DEMAND environment variable for softwareupdate, you can force softwareupdate to install the latest Java update from Apple. This allows you to leverage softwareupdate to re-install the updated Java for OS X 2013-004 over an existing Java for OS X 2013-004 installation that included the problematic Java build.

Michael Kuron posted a script to the MacEnterprise list that I’ve modified. The modified script works pretty well in my environment and does the following:

1. Checks the current OS to see if the Mac is running Mac OS X 10.7.x or later. If not, the script will exit and display the following message:

Not supported on this version of Mac OS X

If the Mac is running 10.7.x or higher, the script runs the following actions:

2. Checks the Java version and displays the results

3. Sets the JAVA_INSTALL_ON_DEMAND environment variable

4. Uses the softwareupdate tool to check for and get the name of the latest Apple Java update for 10.7.x and 10.8.x

5. Installs the latest available Apple Java update for 10.7.x and 10.8.x

6. Checks the current Java version and displays the results

#!/bin/bash
# Original version of this script posted by
# Michael Kuron <michael-lists@PHYSCIP.UNI-STUTTGART.DE>
# Posted to the MacEnterprise list on June 22, 2013:
# http://tinyurl.com/m8fp4ou
#
# This script works on Mac OS X 10.7.0 and higher
#
# Determine OS version
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
if [[ ${osvers} -ge 7 ]]; then
# Checks the current Java version and displays the results
java -version
# Set the JAVA_INSTALL_ON_DEMAND
# environment variable. This variable
# overrides the install check and forces
# the softwareupdate tool to install Apple's
# latest Java 6 update
export JAVA_INSTALL_ON_DEMAND=1
# Uses the softwareupdate tool to check
# for and get the name of the latest Apple
# Java update for 10.7.x and 10.8.x
pkgname=$(softwareupdate --list | grep '*' | grep -i java | awk '{print $2}')
# Installs the latest available Apple
# Java update for 10.7.x and 10.8.x
softwareupdate --install $pkgname
# Checks the current Java version and displays the results
java -version
else
echo "Not supported on this version of Mac OS X"
fi
view raw gistfile1.sh hosted with ❤ by GitHub

For those interested, the script is available on my GitHub repo:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/install_apple_java_on_demand