title: How do I fix Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java?
body: <p>I looked at every stackoverflow question related to the error:</p>
  
  <pre><code>Error: JAVA_HOME is not defined correctly.
    We cannot execute /usr/libexec/java_home/bin/java
  </code></pre>
  
  <p>Still not able to fix it.</p>
  
  <p>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.</p>
  
  <p>My current .bash_profile is:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Trying to execute:</p>
  
  <pre><code>/develop/tools/apache-maven-3.2.5/bin/mvn eclipse:clean eclipse:eclipse -P ut -f /develop/projects/mynavi.wedding/source/pom.xml
  </code></pre>
  
  <p>Any suggestions?</p>