Blaze
Blaze

Reputation: 59

How do I fix Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java?

I looked at every stackoverflow question related to the error:

Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/libexec/java_home/bin/java

Still not able to fix it.

I've been using Java 8 but I have to now use Java 6 for a different project. I feel like some settings from Java 8 is creating this issue.

My current .bash_profile is:

export JAVA_HOME=$(/usr/libexec/java_home)
# export JAVA_HOME=`/usr/libexec/java_home`
# echo export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
# echo export PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Trying to execute:

/develop/tools/apache-maven-3.2.5/bin/mvn eclipse:clean eclipse:eclipse -P ut -f /develop/projects/mynavi.wedding/source/pom.xml

Any suggestions?

Upvotes: 0

Views: 2226

Answers (2)

clstrfsck
clstrfsck

Reputation: 14829

You could try:

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

Then test with:

java -version

Assuming you have Java 1.6 installed, and your path set up you should get something like:

Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)

Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)

Upvotes: 2

Aniruddha Deb
Aniruddha Deb

Reputation: 272

The following has been tested on my mac:

export JAVA_HOME="`/usr/libexec/java_home`"

Upvotes: 0

Related Questions