title: Maven Installation under Windows: "JAVA_HOME is set to an invalid directory"
body: <p>I'm new to Maven and I have downloaded the 3.0.5 version. I'm getting the following error:</p>
  
  <pre><code>JAVA_HOME is set to an invalid directory. please set the java_home variable in your environment variable to match the location of your java installation
  </code></pre>
  
  <p>Although, I see no error when I type <code>javac</code> or echo <code>%M2_HOME%</code> in the command prompt.</p>
  
  <p>I have the following path variables set  -</p>
  
  <pre><code>CLASSPATH - ;C:\Program Files (x86)\Java\jdk1.7.0_40\lib;
  JAVA_HOME - C:\Program Files (x86)\Java\jdk1.7.0_40\bin
  M2 - %M2_HOME%\bin
  M2_HOME - C:\Users\cbil\Documents\Maven\apache-maven-3.0.5-bin\apache-maven-3.0.5
  MAVEN_OPTS - -Xms256m -Xmx512m
  PATH - C:\Program Files\Java\jdk1.7.0_45\bin;C:\Users\cbil\Documents\Maven\apache-maven-3.0.5-bin\apache-maven-3.0.5\bin;
  </code></pre>
  
  <p>Can someone please help me?</p>