In this tutorial, we will learn steps to resolve the following Fatal error compiling: invalid target release: <version number> in Maven Project.
When we build the Maven project, the following error pops up. For more details run the maven command with -X option.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project DocsJBehave: Fatal error compiling: error: invalid target release: <version number> -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project DocsJBehave: Fatal error compiling
The problem is that there is mismatch in the Java/JDK versions. The project is trying to use a particular Java version to build the project. However, the system doesn’t support the Java version the project is intended to build upon.
First things first, decide on which Java/JDK version you want to use. Check the project configuration files pom.xml to know the details.
If the information is not in the project. Check the IDE configuration.
System JDK Information
Check the System Information.
\> echo %JAVA_HOME%
$ echo $JAVA_HOME
In this example, we will fix the Project setup. we will just change the Maven configuration to use JDK 14.
Update the Project and Build it from the IDE.
Alternatively, run the mvn clean install -X from the command shell.
Run the build tool in debug mode to know what exactly happens under the hood. This approach can be followed to identify any other problems in the project as well.
That’s it. In this tutorial, we have learn how to troubleshoot Maven project errors.
Maven Tutorials on this website can be found at:
For more details on the Apache Maven, visit the official website at: