I just moved over to Mac (again) and the first thing when started Java Programming was how to get Java_Home in place. While Mac makes a lot of things easy, programming is where it takes you all back to the root. After much finding and reading I found that the following worked.
1. Start the Terminal application
2. Create or Edit a file with the name.location “~/.bash_profile file”. Do $ vi ~/.bash_profile
3. Put the following line in the file (if it is broken down to 2 lines put it in a single line)
4. Save the file.
5. Restart the Terminal and then try $ echo $JAVA_HOME
And you are all set