1

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 1

2

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
  • Thanks David, but I just figured out what is the issue. I changed from bash to zsh and declaration has to be in .zshrc (I am still looking for way to point to .bash_profile instead of maintaining to path definitions)
    – peter_budo
    Commented Jun 28, 2016 at 14:04
  • David I am not trying to invalidate your answer. My apology if I gave you that impression. In all fairness I did not realised that these two things are related, therefore I did not included in original question.
    – peter_budo
    Commented Jun 28, 2016 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .