Search code examples
mavenenvironment-variablesjava-home

How to fix 'The JAVA_HOME environment variable is not defined correctly' error when JAVA_HOME variable is set correctly?


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.

Error:

C:\WINDOWS\system32>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

Environmental Variables in laptop:

Environmental Variables

Solutions tried so far:

  1. Almost all answers suggest declaring the JAVA_HOME variable correctly, which I have already done.
  2. Ensured 'bin' is not added in JAVA_HOME variable.
  3. Tried declaring JAVA_HOME via UI and via command prompt.
  4. Restarted my laptop multiple times.

Any possible solution is appreciated.


Solution

  • As Mark Rotteveel mentioned, removing the semi colon at the end fixed the error. I'm able to run maven commands now.