I have set java_home on my mac, by putting export JAVA_HOME=/System/Library/Frameworks/JavaVM.frameworks/Home to my ~/.profile file. I quit the terminal and ran it again.

But when I typed echo $JAVA_HOME and pressed Enter it shows JAVA_HOME=/System/Library/Frameworks/JavaVM.frameworks/Version/1.6.0_22/Home which is not the right one. How can I fix this problem & change this ?

link|improve this question

25% accept rate
What Mac OS X version are you using? Try navigating to /System/Library/Frameworks/JavaVM.frameworks/ and open Home to see if it's an alias. Command-click the folder name in the title bar to see the full path. If it's /System/Library/Frameworks/JavaVM.frameworks/Version/1.6.0_22/Home, the alias was simply resolved. – Daniel Beck Feb 1 '11 at 9:25
feedback

1 Answer

Since 10.6 (I think -- may be earlier), the recommended way of setting the JAVA_HOME variable is using /usr/libexec/java_home, via something like

% export JAVA_HOME=`/usr/libexec/java_home`

There are various options you can add to the command to select a suitable JAVA_HOME given various constraints. See the java_home manpage for details.

The general idea is that the structure under /System/Library/Frameworks/JavaVM.frameworks isn't documented and may in principle change from release to release.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.