How To Set $JAVA_HOME Environment Variable On Mac OS X

In this article we show you how to set $JAVA_HOME environment variable on Mac OSX 10.5 or later.

Set the $JAVA_HOME variable to /usr/libexec/java_home, just export $JAVA_HOME in file ~/. bash_profile or ~/.profile as shown below

 
$ vim .bash_profile 
 
export JAVA_HOME=$(/usr/libexec/java_home)
 
$ source .bash_profile
 
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

Orginal Article from Mkyong.com

Labels

java java Delete
macosx macosx Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.