简体   繁体   中英

Set JAVA_HOME on Mac

I´ve tried everything but can´t set JAVA_HOME on a mac. Some say´s all you got to do is echo export "JAVA_HOME=\\$(/usr/libexec/java_home)" >> ~/.bash_profile

I did, and restarted my shell and this is what it shows up:

-bash: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home: is a directory

This ALWAYS shows up no matter which method of setting the variable I´ve used. My jdk 7 that I want to use is in my Library but the 1.6 that´s being used now is in System folder.

I have two versions of Java installed - 1.6 and 1.7 on my mac. Depend upon which version I would like to use, I just change the entry in .bash_profile file.

Below is my .bash_profile looks like for version 1.6

cat .bash_profile

export JAVA_HOME='$(/usr/libexec/java_home -v 1.6)'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM