title: Error: JAVA_HOME is not defined correctly executing maven
body: <p>I installed java and set the path environment and when I run <code>echo $JAVA_HOME</code> in the terminal I get the following output:</p>
  <pre><code>/usr/lib/jvm/java-7-oracle/jre/bin/java
  </code></pre>
  <p>I Also installed <code>apache-maven</code> and changed <code>environment</code> file and now it looks like this:</p>
  <pre><code>JAVA_HOME=&quot;/usr/lib/jvm/java-7-oracle/jre/bin/java&quot;
  M2_HOME=/usr/local/apache-maven/apache-maven-3.0.5
  M2=$M2_HOME/bin
  MAVEN_OPTS=&quot;-Xms256m -Xmx512m&quot;
  PATH=$M2:$PATH
  </code></pre>
  <p>But when I execute <code>mvn --version</code> I get a warning:</p>
  <pre><code>Error: JAVA_HOME is not defined correctly.
    We cannot execute /usr/lib/jvm/java-7-oracle/jre/bin/java/bin/java
  </code></pre>
  <p>Can not find out why it repeats in the end <code>/bin/java/bin/java</code></p>