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.