Solved: Java compiler level does not match the version of the installed Java project facet

I have been facing this issue from quite long time as I didn’t took care of it. Everytime I faced this issue, I just went and changed the project compiler level for projects facets menu in eclipse. Today, I decided to end this for all.

This error looks like in eclipse is as follow:

Maven compiler level mismatch error
Maven compiler level mismatch error

Reason:

This error is because of maven compiler plugin defaults. Which is currently 1.5. So if you are using java 1.6 for building your project, you are going to face this issue every time you run this command:

mvn eclipse:eclipse -Dwtpversion=2.0

According to maven documentation : “at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler.”

My case was worse because at that time default was java 1.4. :-(

Solution:

To solve this issue, you need to make one time update in your pom.xml file. This update is for overriding the default compiler level in maven compiler plugin.

<plugins>
	<plugin>
	  <artifactId>maven-compiler-plugin</artifactId>
		<configuration>
		  <source>1.6</source>
		  <target>1.6</target>
		</configuration>
	</plugin>
</plugins>

Update above compiler properties with your desired java version. And place this configuration inside “build” node in pom.xml file like this:

<build>
	<finalName>JerseyHelloWorld</finalName>
	<plugins>
		<plugin>
		  <artifactId>maven-compiler-plugin</artifactId>
			<configuration>
			  <source>1.6</source>
			  <target>1.6</target>
			</configuration>
		</plugin>
  </plugins>
</build>

Above change will correct the error.

Happy Learning !!

Reference: http://maven.apache.org/plugins/maven-compiler-plugin/

Comments

Subscribe
Notify of
guest
9 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial

Dark Mode

Dark Mode