Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to locate an executable at "/usr/bin/java/bin/java" (-1)

Tags:

java

macos

javac

I am having a pathetic issue with Java in my mac osx 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

Output of which java

/usr/bin/java

Its bugging me for long days and uninstalling and installing java did not help my luck .

I am a newbie in Mac and need help to sort out this issue .

Googled and saw SOF before posting this question but did not find anything specific to my problem .

Thanks

Sabya

like image 525
Sabya Avatar asked Jun 03 '12 19:06

Sabya


2 Answers

Most certainly, export JAVA_HOME=/usr/bin/java is the culprit. This env var should point to the JDK or JRE installation directory. Googling shows that the best option for MacOS X seems to be export JAVA_HOME=/Library/Java/Home.

like image 156
Alexander Pavlov Avatar answered Oct 19 '22 08:10

Alexander Pavlov


export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

Because:

 $ find /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home -name java*
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javac
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javadoc
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javafxpackager
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javah
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javap
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javapackager
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/javafx-src.zip
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/bin/java
like image 15
Ankur Agarwal Avatar answered Oct 19 '22 09:10

Ankur Agarwal