A maven is a powerful tool for building this error. I will explain why this error happens and how to solve this error:
The java Home problem?
After installing Maven, the user has to set the Java_Home environment variable. So the tools know where to find the JDK commands to execute. Maven runs the appropriate java commands against the project source code.
The most common scenario is to compile the code by using the java command. If the java_home is not pointing to a valid JDK installation, then mevan will throw an error at every execution.
“JAVA_HOME should not point to a JDK nor JRE”
Make sure you don’t have a JRE path if you have the delete it.
- Add the JAVA_HOME to system variable, Variable value is C:\Program Files\Java\jdk-10.0.2 (location of JDK without bin).
- Add M2 in the system variable. Variable Value: C:\dev\maven\apache-maven-3.5.4 ( location of maven with bin).
- Add M2_HOME in the system variables. Variable value: C:\dev\maven\apache-maven-3.5.4 (location of maven with bin).
- Add %JAVA_HOME% and %M2% in Path System Variable or C:\Program Files\Java\jdk-10.0.2 and C:\dev\maven\apache-maven-3.5.4\bin.
For Windows 10, just add the location. For other versions, at the end of Variable Value Field add a semicolon and then location like;%JAVA_HOME%;%M2%