Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

IS this line enough for setting JAVA_HOME in OS x mountain lion:

/usr/libexec/java_home -v 1.7.0_17 --exec javac -version

I have seen other solutions, but I can figure out how i should use them. For example one of them suggests to edit .bash file, I "tried" to do it once but failed miserably.I appreciate any help :) Thanks a lot in advance ..

share|improve this question
What do you want to set it for? How you want to use it affects how it is set. – Mark Mar 27 '13 at 0:45
I am learning to code on Java Eclipse EE indigo. It was working fine, until I started to use WindowBuilder. My project compliance was set to JDK 1.7. Even when i use "Java -version" it says my VM is set to 1.7. For some reason my Eclipse was still using the JAVA_HOME from jdk 1.6 which was located in /system/library/java.. instead of the one I installed from oracle. So I thought to reinstall Mountain Lion, and avoid installing Java SE 6. Now the problem is I cant even open eclipse. It wants me to install JAVA Se 6. – Arvind Ab Mar 27 '13 at 9:39
Does the command line you show not work? .bashrc editing will fail as Eclipse or any app run from the Desktop or other GUI will not read that – Mark Mar 27 '13 at 12:37
One fix might be to use eclipse Juno which runs on JDk 7 – Mark Mar 27 '13 at 12:43
the command works. My problem now is My eclipse ignores the JDK 7. I have also edited the eclipse.ini file by this lines: -vm /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre/bin/java/ before the -vmargs but still wont work – Arvind Ab Mar 27 '13 at 13:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.