$vim .bash_profile
Adicione as seguintes linhas abaixo no arquivo:
export JAVA_HOME=$(/usr/libexec/java_home)
execute the source command
$ source .bash_profile
echo JAVA_HOME:
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home