Unable to locate an executable at "/usr/bin/java/bin/java" 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.
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).