Skip to content

Update Java JDK 8 on Mac OS X 10.11

Updates are annoying, but have to be conducted anyway. Here’s how to quickly update your Java JDK on Mac OS X 10.11.

Check which version of Java JDK you are running by opening a new Terminal and typing:

$ java -version

This will give you an output like the following:

$ java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

In my case, I’m running an old Java JDK version which is Java 8 Update 11 (as indicated by 1.8.0_11).

Running the command

$ /usr/libexec/java_home

gives you the path where your current Java is installed. In my case, this is:

$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home

Now, download the latest version as DMG file from Oracle page at http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Run the DMG and install Java as usual.

If you now run the tool for determining the Java home path again, you can see that it changed to the new version:

$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home

You can remove the old Java version with the command

$ rm -R /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/

To set the $JAVA_HOME variable you can edit your .profile. Open the file with vi:

$ vi ~/.profile

Add the following line

export JAVA_HOME=`/usr/libexec/java_home`

Or if you have more than one version of Java installed you could use

export JAVA7_HOME=`/usr/libexec/java_home -v 1.7`
export JAVA8_HOME=`/usr/libexec/java_home -v 1.8`
export JAVA_HOME=$JAVA8_HOME

Where -v 1.x tells java_home for which Java version you want to know the home directory.

Leave a Reply