Setup Mac OS JAVA_HOME

I have fresh installation of OS X El Captain version 10.11.5. In my .bash_profile I did setup Java home as

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

However if I type echo $JAVA_HOME results is empty line. My version of Java is 1.8.0_92

EDIT: At the time of writing I did not included not about using zsh instead of default shell. I did not linked the issue with changed of shell type.

1 Answer

echo $JAVA_HOME results in an empty line

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)"

or

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

or

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

Source Where is JAVA_HOME on OSX Yosemite (10.10), Mavericks (10.9), Mountain Lion (10.8) or OSX Lion (10.7)?, answer by Olivier Refalo

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like