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

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

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest