Tag Archives: JAVA_HOME not found in your environment

Maven configuration error: JAVA_HOME not found in your environment

Recently, I was relatively empty and wanted to study spring mvc, so I compiled the development environment step by step according to the tutorial. After configuring maven, when running the command mvn -v, an error was reported. The error message is as follows:

Error: JAVA_HOME not found in your environment.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

I carefully checked the configuration of JAVA_HOME and found that there is no problem. Why does it prompt this error?

I searched the Internet,

Some say that JAVA_HOME should point to the root directory of jdk and cannot contain /bin;

Some say that there cannot be a semicolon after the JAVA_HOME path;

Some say that there should be no spaces in the path, such as “Program Files” such path.

I checked these items one by one, but it didn’t solve my problem.

In the end, I found the problem accidentally, and found that when I run cmd as an administrator, this error will not be reported.