In fact, the reason is very simple, because the jdk configuration of java is not in compliance with the standard!
First, I am win10 system.
2. My java jdk is placed on the D drive. In the environment variable, JAVA_HOME is D:\Program Files\Java\jdk1.8.0_101\bin, and there is %JAVA_HOME% in the path.
Download and install maven
Download it from the maven official website http://maven.apache.org/ .
Download the latest version of maven to the local, extract it to the apache-maven-3.5.2-bin folder on the D drive, and then set MAVEN_HOME in the environment variable to D:\apache-maven-3.5.2-bin\apache-maven -3.5.2\.
Add %MAVEN_HOME%\bin to path. Click OK all the way. Then open win+R. cmd to enter.
Type: mvn --v
turn out:
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.
Analyze the reason for the error:
The reason is that JAVA_HOME should be set to D:\Program Files\Java\jdk1.8.0_101\, and in path, changed to %JAVA_HOME%\bin.
After clicking OK all the way, close the previously opened cmd window, reopen a cmd window, and test mvn -v at this time, which is successful.
in conclusion:
Configure environment variables in the future. HOME is HOME, which means base camp. Don't configure HOME too finely! Write the word bin in the path, not in HOME! ! !