OSX Lion JAVA_HOME

Apple’s OS Lion has a pretty neat trick for handling the JAVA_HOME variable

<br /> Chill:bin rus$ /usr/libexec/java_home<br /> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home<br />

which is super awesome as you can simply do

<br /> Chill:bin rus$ export JAVA_HOME=$(/usr/libexec/java_home)<br /> Chill:bin rus$ echo $JAVA_HOME<br /> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home<br />

to make sure you have the correct $JAVA_HOME set up, every time!

I’ve added this commend to my ~/.profile file so that whenever I open a new terminal, the $JAVA_HOME variable gets set correctly!