2

I am having an issue with Java in my Mac (OS X 10.7.3). Previously I installed it and it was working fine. After some changes in the .bash_profile and .profile file in the course of time, I am having an error like Unable to locate an executable at "/usr/bin/java/bin/java" whenever I try to run "javac" or "java" in my terminal.

echo $PATH gives an output like:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/sabya/Documents/Play_Framework/play-2.0:/usr/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin

My .bash_profile looks like:

alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
export JAVA_HOME=/usr/bin/java

Its bugging me for several days and reinstalling Java did not help. I'm a newbie in Mac and need help to sort out this issue. I Googled before posting this question but did not find anything relevant.

6

You probably can just remove the definition of JAVA_HOME from .bash_profile and restart the shell. If you really need to set the variable, use

export JAVA_HOME=$(/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java_home)

to define it dynamically depending on the installed JDK version or

export JAVA_HOME=/Library/Java/Home

to use the default place (which is symlinked to the above path).

  • Another trick worked . I just edited the .bash_profile and exported the JAVA_HOME as export JAVA_HOME=/Library/Java/Home . It solved the problem . – Sabya Jun 3 '12 at 20:12
  • Indeed :-) It's a symbolic link leading (after some more redirections) to the same place. I've extended the answer accordingly. – nohillside Jun 4 '12 at 5:06
  • Frequently you do not even need JAVA_HOME – Thorbjørn Ravn Andersen Jun 5 '12 at 19:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .