Today I had to built a legacy Java project on my MacBook, but my JAVA_HOME environment variable had to be defined as a Maven property. So I had to find my JAVA_HOME directory on my Mac OSX, which turned out to be very easy.
We can simply use /usr/libexec/java_home
and the result is the location of our JAVA_HOME on our computer.
$ /usr/libexec/java_home /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home