Olivier Refalo Olivier Refalo - 1 year ago 67
Java Question

Where is JAVA_HOME on OSX Yosemite (10.10), Mavericks (10.9), Mountain Lion (10.8) or OSX Lion (10.7)?

Java is an optional package on the latest versions of OSX.

Yet once installed it appears like the JAVA_HOME environment variable is not set properly.

Answer Source

With the Java optional package or Oracle JDK installed, adding one of the following lines to your ~/.bash_profile file will set the environment variable accordingly.

export JAVA_HOME="$(/usr/libexec/java_home -v 1.6)"
export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)"
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

Update: added -v flag based on Jilles van Gurp response.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download