title: How to fix 'The JAVA_HOME environment variable is not defined correctly' error when JAVA_HOME variable is set correctly?
body: <p>I'm trying to set up a project in my new laptop. While doing so, I faced this error even though the JAVA_HOME variable is set correctly.</p>
  <p><strong>Error</strong>:</p>
  <pre><code>C:\WINDOWS\system32&gt;mvn -version
  The JAVA_HOME environment variable is not defined correctly
  This environment variable is needed to run this program
  NB: JAVA_HOME should point to a JDK not a JRE
  </code></pre>
  <p><strong>Environmental Variables in laptop:</strong></p>
  <p><a href="https://i.stack.imgur.com/Vp1qU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vp1qU.png" alt="Environmental Variables" /></a></p>
  <p><strong>Solutions tried so far</strong>:</p>
  <ol>
  <li>Almost all answers suggest declaring the JAVA_HOME variable correctly, which I have already done.</li>
  <li>Ensured 'bin' is not added in JAVA_HOME variable.</li>
  <li>Tried declaring JAVA_HOME via UI and via command prompt.</li>
  <li>Restarted my laptop multiple times.</li>
  </ol>
  <p>Any possible solution is appreciated.</p>