Maven compiles and hits the following fatal error messages:

mvn compile

Fatal error compiling: error: invalid target release: 1.11

pom.xml

	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-compiler-plugin</artifactId>
		<version>3.8.1</version>
		<configuration>
			<source>1.11</source>
			<target>1.11</target>
		</configuration>
	</plugin>

Solution

For maven-compiler-plugin, the correct JDK version is 1.8, 1.9, 1.10, 10, 11, 12 ... 17 ...

pom.xml

	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-compiler-plugin</artifactId>
		<version>3.8.0</version>
		<configuration>
			<source>11</source>
			<target>11</target>
		</configuration>
	</plugin>

or

	<properties>
		<java.version>11</java.version>
	</properties>

Note
Also, ensuring the JAVA_HOME environment variable is pointing to the correct Java 11. Read this similar error invalid target release: 17

References

Leave a Reply

Your email address will not be published. Required fields are marked *