Reputation: 9977
When I enter
java -version
it returns
Unable to locate an executable at "/System/Library/Frameworks/JavaVM.framework//bin/java" (-1)
If I enter
which java
it returns
/usr/bin/java
I have looked online and found very similar problems but the general solution of editing the bash_profile and adding the code below does not work
export JAVA_HOME=/Library/Java/Home
Any help on how to solve this will be greatly appreciated.
Upvotes: 0
Views: 2705
Reputation: 12527
The java in /usr/bin is just a symbolic link to /System/Library/Frameworks/JavaVM.framework//bin/java. This is standard on MacOS. It sounds like target of the symlink does not exist. You can fix this in one of two ways.
To manually update the symlink, you will need admin privileges. Thus if the commands below do not work, try running them via sudo (i.e. put sudo in front of each command). Note the commands below assume you have java 1.6 installed. You will have to search your system to see exactly what versions are there an use the appropriate path the the java executable.
cd /usr/bin
rm java
ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java
Upvotes: 2