Java 1.7 update for Mac OS 10.8 Mountain Lion for JDK 7 support

Needed to update to JDK 7 for some maven projects and it wasn’t quite as straightforward as one might think. Check

java -version

and if you have 1.6 and are on Lion or greater (10.7+), download the JDK from here:

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html (or search for JDK 1.7 download). Note a casual search for Java 7 will most likely get you the JRE not the JDK.

If you are not on 10.7+ (some of my Macs are ~stuck on 10.6), seems you are out of luck without doing some pretty extraordinary work-arounds.

After installing the dmg file, check java version again – if it’s still 1.6, you may need to update the /usr/bin/java symlink with something like:

sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java /usr/bin/java

and update JAVA_HOME with:

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`

Note the backticks above. (Add to your bash_profile or similar to avoid having to set it manually.)

Leave a Reply