Install Java on Mac OS X

A short how-to for installing and configuring Java Development Kit on Mac OS X.

Java is core technology used by CI servers like Jenkins, Bamboo and others. It is also used by Atlassian CLI Client. In fact installing and configuring JDK is such a common task that it deserves its own post.

Java Version

Select JDK version which you need: 1.6, 1.7 or 1.8. Better install all of them, you never know what you might need one day.

I find that for most applications I’m using 1.7, rarely 1.6 for some outdated and unsupported application. These days more and more applications are updated to work with 1.8 without issues.

Java Home

Lots of applications, if not all, expect JAVA_HOME environment variable to be set. This tells them where the Java Virtual Machine (JVM) is located. I would recommend to update your ~/.bash_profile and add something like this:

This is an over-defensive version. It can safely run on OS other than Mac, but will not set JAVA_HOME in that case. It uses OS X specific java_home executable found in /usr/libexec. A very convenient utility to get JVM path for Java installation. Try -V to get a list of all JVMs installed.

If you are using shell other than bash, include the same in your shell’s version of .bash_profile or source it directly with source .bash_profile.

Published: February 15 2015

blog comments powered by Disqus