HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / Maven / Solved: Java compiler level does not match the version of the installed Java project facet

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/

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Reddit

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Feedback, Discussion and Comments

  1. sasikanta

    January 15, 2018

    MY project is non maven . and my project faced is locked . kindly any solution.

  2. apurva

    February 26, 2015

    This solved my problem:
    go to window -> preferrences->java>compiler (set to 1.6 already) again apply changes and –> OK

    • Lokesh Gupta

      February 26, 2015

      Thanks for sharing.

  3. siddhesh deodhar

    May 26, 2014

    Well, even after doing this if you still get problem then just go to your workspace folder and delete .settings folder of your project and refresh your project in eclipse. Cheers.

    • Lokesh Gupta

      May 26, 2014

      Thanks for adding value to this post.

  4. James

    May 15, 2014

    Still having the issue here. Using STS

  5. james m

    April 1, 2014

    This solved my maven building issues, thanks very much

  6. pavan

    March 9, 2014

    Thanks much for sharing your solution …

  7. Yu Jing

    August 8, 2013

    Great! Thanks for your article.
    BTW,when I input my e-mail, It automatically filled the name && website, how to achieve it?

    • Lokesh Gupta

      August 8, 2013

      Its browser specific. Nothing from my blog side.

Comments are closed on this article!

Search Tutorials

Maven Tutorial

  • Maven – Installation
  • Maven – Settings
  • Maven – Dependency Mgmt
  • Maven – Dependency Scopes
  • Maven – POM
  • Maven – Parent POM
  • Maven – Repositories
  • Maven – Local Repo Path
  • Maven – M2_REPO
  • Maven – Network Proxy
  • Maven – Enforce Java Versions
  • Maven – Simple Java Project
  • Maven – Web Project
  • Maven – Multi-module Project 1
  • Maven – Multi-module Project 2
  • Maven – Java Source Folders
  • Maven – BOM [Bill Of Materials]
  • Maven – Import Remote Catalogs
  • Maven – Create Custom Archetype
  • Maven – Compiler Level Mismatch
  • Maven – Ant Build
  • Maven – IntelliJ
  • Maven – JSTL Support
  • Maven – Tomcat Plugin
  • Maven – Uber Jar for Spring Boot
  • Maven – Shade Plugin
  • Maven – Remove corrupt jars

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Java 15 New Features
  • Sealed Classes and Interfaces
  • EdDSA (Ed25519 / Ed448)