title: Error: JAVA_HOME is set to an invalid directory
body: <p>I am trying to get maven installation to work but I am always getting this error</p>
  
  <blockquote>
    <p>C:\Windows\System32>mvn --version<br>
    Error: JAVA_HOME is set to an invalid directory.<br>
    JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_51;"<br>
    Please set the JAVA_HOME variable in your environment to match the
    location of your Java installation.</p>
  </blockquote>
  
  <p>I know that the error says every thing but I have tried everything here. I have the following setting:</p>
  
  <p>System Variables:</p>
  
  <p><strong>M2_HOME:</strong>   C:\Program Files\Apache Software Foundation\apache-maven-3.3.3</p>
  
  <p><strong>M2:</strong>         %M2_HOME%\bin</p>
  
  <p><strong>JAVA_HOME:</strong>  C:\Program Files\Java\jdk1.7.0_51</p>
  
  <p>I added the whole path maybe it is interested someone. please take a look at the last part.</p>
  
  <p><strong>Path:</strong>  </p>
  
  <pre><code>C:\Program Files\Java\jdk1.7.0_51\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;%M2%;%JAVA_HOME%\bin;
  </code></pre>
  
  <p><strong>Path interested part:</strong></p>
  
  <pre><code>%M2%;%JAVA_HOME%\bin;
  </code></pre>
  
  <p>I have tried it by deleting the <code>%JAVA_HOME%\bin;</code> too but it does not work since I have this path by the SDK installation at the start of the path  <code>C:\Program Files\Java\jdk1.7.0_51\bin</code></p>
  
  <p>I have tried to add the setting to the user variables and it does not work.</p>