There are several reasons for the java_home not found in your enviroment error
1. The JAVA_HOME system environment is not configured, the JAVA_HOME environment variable configuration method:
<1> Right click on the computer icon -> Properties -> Click "Change Configuration" -> Advanced -> Environment Variables -> System Variables -> Click "New" -> Variable Name: JAVA_HOME, Variable Value: JDK's root directory (* **/jdk1.xx) Note: ";" cannot be added after the path
<2>CLASSPATH system environment variable configuration method: Right click on the computer icon -> Properties -> Click "Change Configuration" -> Advanced -> Environment Variables -> System Variables -> Click "New" -> Variable Name: CLASSPATH, Variable Value : ".;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;"
<3>Path system environment variable configuration method: Right-click the computer icon -> Properties -> Click "Change Configuration" -> Advanced -> Environment Variables -> System Variables -> Click "New" -> Variable Name: Path, Variable Value : ";%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;" (the first one in front of the variable value; add it as the case may be, if there is already one at the end of the Path; do not need to add it, if there is no need to add it)
<4>M2_HOME user environment variable configuration method in maven:: Right click on the computer icon -> Properties -> Click "Change Configuration" -> Advanced -> Environment Variables -> User Variables -> Click "New" -> Variable Name: M2_HOME, variable value: maven installation path (the unzipped path after downloading "X disk:\a directory\apache-maven-3.3.9-bin\apache-maven-3.3.9")
<5> PATH user environment variable configuration method in maven: Right click on the computer icon -> Properties -> Click "Change Configuration" -> Advanced -> Environment Variables -> User Variables -> Click "New" -> Variable Name: PATH, variable value: %M2_HOME%\bin;%JAVA_HOME%\bin;
2. If all of the above have been configured, run mvn -r in cmd. If it fails, it will prompt java_home not found in your enviroment to see if cmd is running as an administrator. The method of running cmd as an administrator: Open C:\Windows \System32 directory, find cmd.exe, right-click to run as administrator, enter mvn -r to see if it is successful
3. If the cmd and administrator mode fails, start to check whether you have accidentally made a mistake when configuring the environment variables. Find the reason: open cmd, enter echo %JAVA_HOME%, and the output string cannot be followed by ';', Because the value of the CLASSPATH variable adopts the variable of JAVA_HOME, for example: "C:\Program Files (x86)\Java\jdk1.7.0_25" output by JAVA_HOME, and CLASSPATH = %JAVA_HOME%\lib\dt.jar is equivalent to CLASSPATH = C :\Program Files (x86)\Java\jdk1.7.0_25\lib\dt.jar, if the echo output value of JAVA_HOME is configured as JAVA_HOME = "C:\Program Files (x86)\Java\jdk1.7.0_25;" then CLASSPATH = C:\Program Files (x86)\Java\jdk1.7.0_25;\lib\dt.jar, the system cannot find the dt.jar package, resulting in failure (if it still fails, check if M2_HOME is configured There is a problem accidentally), the above should solve the problem of java_home not found in your enviroment, if there is anything wrong in the middle, please give me some pointers, my brother would like to thank you in advance