To find the right value that JAVA_HOME should be set to.
1. first executed a `which java` in the nearest Terminal. this told me that /usr/bin/java was the executable that launched the VM.
2. A quick `ls -l /usr/bin/java` told me that it wasn’t a symbolic link to the JDK installation that I was hoping for. Instead, it is a short shell script that executes:
in the terminal, it’ll return /usr/bin/java. (which in turn points to
/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java, which is Apple’s 1.6 version).
3. So, if you want to use the new java version, replace the /usr/bin/java symlink so that it points to
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java instead.
4. The command could be:
sudo ln -fs /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin/java
5.Sanity check your version: