Home > Java, Mac administration, Mac OS X, Scripting > Automating Oracle Java 7 updates

Automating Oracle Java 7 updates

Something I’ve wanted to do for a while was to write a script to download and install the latest Java 7 update from Oracle. I’ve been using AutoPkg to download the latest Java 7 updates using AutoPkg’s OracleJava7 recipes, but I wanted to develop a script that would do the following:

  1. Download the latest Java 7 installer from Oracle’s website
  2. Install the latest Java 7 update
  3. Clean up after itself

Oracle didn’t make this an easy task, as the download URL seems to change on a per-update version. AutoPkg handles its update task by scraping Oracle’s manual download page for the current correct URL to use.

Oracle does provide a Sparkle-based update mechanism for Java 7 on OS X, so I wanted to see if there was a way to leverage that to pull down updates. The only address I could find in that regard was the SUFeedURL value included in Java 7’s /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist file. I checked that value using the following command:

defaults read "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info" SUFeedURL

The output I received for Java 7 Update 67 was the following:


I decided to see what output would come back from Oracle’s site when accessed, so I used the following curl command to see what was returned:

/usr/bin/curl --silent https://javadl-esd-secure.oracle.com/update/mac/au-1.7.0_67.xml 

The following XML was returned and I was gratified to see that it contained a download link to a Java 7 Update 67 disk image.

Screen Shot 2014-08-16 at 5.58.35 PM

One of the important things I was able to establish is that the XML address embedded with Java 7 Update 67 is not special in this regard. As part of my testing, I verified that using the SUFeedURL value for Java 7 Update 15 and 65 will also work to pull the address of the latest Oracle Java 7 installer disk image.

Using this information, I was able to build a script that can download and install the latest Java 7 update. See below the jump for details.

Update 3-6-2015: This script has been retired and should no longer be used to install Java 7. It uses Java 7’s update feed to install the latest Java and Oracle has recently updated the feed to begin providing Java 8 to Java 7 users:


The script below will download a disk image containing the latest version of Java 7 from Oracle and install Java 7 using the installer package stored inside the downloaded disk image.

How the script works:

  1. Uses curl to download a disk image containing the latest Java 7 installer from Oracle’s web site.
  2. Renames the downloaded disk image to java_seven.dmg and stores it in /tmp.
  3. Mounts the disk image silently in /tmp. The mounted disk image will not be visible to any logged-in user.
  4. Installs the latest version of Java 7 using the installer package stored on the disk image.
  5. After installation, unmounts the disk image and removes it from the Mac in question.

I’ve posted the script to my GitHub repo at the following address:


This script is also available as a payload-free installer package, stored as a .zip file in the payload_free_installer directory.

  1. Rick W
    September 6, 2014 at 7:32 pm

    This is an awesome script! Quick question though… I’m not seeing anything checking to see what version is currently installed prior to going through the curl/download process.

    Is this script purely for machines that do not have existing installs of Java 7? Or perhaps after a known release is made from Oracle?

    The Flash version check is awesome out there on the ‘net and it checks first to see what you have versus what is out there available for download and abandons if it finds an equal match and continues on with the download if nothing is installed or a newer version is present.

    Thanks for this great site!

    • September 8, 2014 at 1:53 pm

      This script does not check to see if Java 7 is installed, or what version of Java 7 is installed. Here’s what the script does:

      1. Identifies if the Mac in question can run the latest version of Java 7
      2. Identifies the correct download link for the latest version of Java 7
      3. Downloads the appropriate installer.
      4. Installs Java 7 on the Mac using the downloaded installer.

  2. March 6, 2015 at 11:47 am

    installer: Error the package path specified was invalid: ”.

    Is this because its installed already? Im pushing via ARD, Im I right in assuming that this is why its failing?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: