• Register
1 vote
447 views

Problem:

Dear all, Right now I’ve imported a maven project into my eclipse IDE and I changed my java path library to work on java 1.7

Suddenly, eclipse started showing an error but I’ve got no errors in my files there. The error is java compiler level does not match the version of the installed Java project facet

Java compiler level does not match the version of the installed Java project facet.
Unknown Faceted Project Problem (Java Version Mismatch)

Please tell me how to resolve this error (I want to have my JRE version as 1.7 only).

15.3k points
reopened by

Please log in or register to answer this question.

2 Answers

1 vote

Solution:

All you need to change the Java facet version from 1.x to 1.7 (as you said, you want stick-on version 1.7)

Find the project properties and set your java project version to 1.7 using the above screenshot. 

The other possible solution could be the editing of the project settings for facets. Find the .settings folder in your root. Inside the folder, you’ll have a file named: org.eclipse.wst.common.project.facet.core.xml 

The original file is (imaginary):

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="jst.web" version="2.3"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="java" version="1.5"/>
</faceted-project>

Let’s modify it and set the java version to 1.7

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="jst.web" version="2.3"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="java" version="1.7"/>
</faceted-project>

Refresh the project. Now, it should run fine. Thanks.

94.3k points
0 votes

Solution:

Considering that you are employing the m2e plugin in Eclipse, you'll require to seclude the source and target versions as 1.6 for maven-compiler-plugin. m2e uses these values to determine the project's Java compiler level. A snippet of the POM is displayed below:

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

Possibly, you can seclude the maven.compiler.source and maven.compiler.target properties with values of 1.6, that occur to be the equivalent:

<properties>
    <maven.compiler.target>1.6</maven.compiler.target>
    <maven.compiler.source>1.6</maven.compiler.source>
</properties>

In case your project is not a Maven project, right-click on your project and choose Properties to open the Project Properties dialog.

There is a Project Facets item on the left, choose it, search for the Java facet on the list, choose which version you want to use for the project and employ.

TK Gospodinov answer is right even for maven projects. Look out: I do use Maven. The pom was right and still got this problem. I went to "Project Facets" and really removed the Java selection which was pointing to 1.6 however my project is employing 1.7. On the right in the "Runtimes" tab I had to check the jdk1.7 option. Nothing present on the left even after I hit "Apply". The problem went away though which is why I still consider this answer is significant of the earmarked "Project Facets" related issue. Afterwards you hit OK in case you come back to "Project Facets" you will observe Java displays up as version 1.7 hence you can now choose it to ensure that the project is "marked" as a Java project. I also necessary to right click on the project and choose Maven|Update Project.

I altered the configuration inside

workspace/project/.setting/org.eclipse.wst.common.project.facet.core to :
installed facet="jst.web" version="2.5"
installed facet="jst.java" version="1.7"

Before altering config, remove project from IDE. This performed for me.

For solving this problem, you require 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 set this configuration within “build” node in pom.xml file :

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

 

31.7k points
edited by