Main Tutorials

Maven error – invalid target release: 1.11

Maven compiles and hits the following fatal error messages:

Terminal

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

pom.xml

	<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

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
20 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Tamir S
4 years ago

Hey,
I encountered the same issue while upgrading from 1.8 to 11. Please note, that you have to make sure that both JAVA_HOME and Path are updated with JDK 11 under Environment variable.

Jiansen Huang
3 years ago

Thanks for the tutorial. The compile only accept 14 not 14.0.2 or 15 not 15.0.1, that’s really a tiny bug but hard to find out

Ketil Johannessen
3 years ago
Reply to  Jiansen Huang

I experience the same issue on 15.0.1 as you notice. Have you found any resolution to this “tiny bug”?

Bill
4 years ago

Thanks, buddy!

Saad B.
4 years ago

you da real mvp

Abou
1 year ago

Thanks for the tutorial

Nathan
1 year ago

Thank you, the JAVA_HOME was the pb for me

Alvaro
2 years ago

Thank you so much!

Marta
2 years ago

thanks!

Roberto Marquez
2 years ago

Thank you, sir. I was stuck until I read this post.

Demor M
2 years ago

Thank you soo much! I’ve been having issues all day setting up my new project and this helped greatly! ^ _ ^

Jack
3 years ago

It worked. Thanks!

Ramesh
3 years ago

Thank you Dude!

Mudjau
3 years ago

Thanks very much!

Peterson
3 years ago

YOU ARE THE GUY!

Oskar
3 years ago

My mvp too!

sisca
3 years ago

thank you!!!!

LazyBee
3 years ago

Thank you!

Abhishek Chauhan
4 years ago

@Mykong
Thanks bro