Similar problem as posted in Fatal error compiling: invalid target release: 1.8 -> [Help 1] However, problem is not solved after I check my settings with the solutions. Details is as follows.
Maven Error Message is:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
My JAVA_HOME setting is:
C:\Program Files\Java\jdk1.8.0_40
Java -version:
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
I've added compilation detail to pom.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Fix invalid target release error by changing Maven's Java version. You need to install a newer JDK and then update JAVA_HOME or PATH environment variables.
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.
In case of Maven, we specify the compiler plugin to use Maven with Java 17. The next step is to basically upgrade the dependencies of our application.
As discussed in comments, You need to restart your console after setting your %JAVA_HOME%
enviroment variable.
Eclipse Users, Cross check your run configuration in Maven build. Follow steps to correct -
This solution works for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With