score:176

Accepted answer

assuming that you are using the m2e plugin in eclipse, you'll need to specify 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 shown below:

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

alternatively, you can specify the maven.compiler.source and maven.compiler.target properties with values of 1.6, that happen to be the equivalent:

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

score:1

if using eclipse,

under.settings click on org.eclipse.wst.common.project.facet.core.xml

<?xml version="1.0" encoding="utf-8"?>
<faceted-project>
  <installed facet="java" version="1.7"/>
</faceted-project>

change the version to the correct version.

score:2

in eclipse, right click on your project, go to maven> update projetc. wait and the error will disappear. this is already configured correctly the version of java for this project.

enter image description here

score:3

right click the project and select properties click the java compiler from the left and change to your required version hope this helps

score:4

the project facet->java should match whatever you have in the pom.xml for the maven-compiler-plugin artifact source and target.this is perfect.but if you donot have it here then you can also fix it by matching java compiler version in porject-facets from the setting: eclispe->preferences->java->compiler

score:4

you can change project facet from project --> properties --> project facet --> java --> {required jdk version}

score:5

i changed 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 changing config, remove project from ide. this worked for me.

score:5

i resolved it by myproject--->java resource---->libraries-->jre system libraries[java-1.6] click on this go to its "property" select "classpath container" change the execution environment to java-1.8(jdk1.8.0-35) (that is latest)

change the jdk to latest

score:6

i resolved this problem by setting the java version in project facet property of the project properties, right click the project root folder -> properties, search for project facets, and select compatible java version.

for reference -

enter image description here

score:7

i found @bigleftie's comment above very helpful: "four things must match

  1. project->java build path->libraries->jre version
  2. project->java compiler-> compiler compliance level
  3. project->project facets->java->version
  4. (if using maven) pom.xml - maven-compiler-plugin artefact source and target".

in my case, in the project properties, java compiler, the jdk compliance was set to use the workspace settings, which were different from the java version for the project. i clicked on 'configure workspace settings', and changed the workspace compiler compliance level to what i wanted, and the problem was resolved.

score:18

tk gospodinov answer is correct even for maven projects. beware: i do use maven. the pom was correct and still got this issue. i went to "project facets" and actually removed the java selection which was pointing to 1.6 but my project is using 1.7. on the right in the "runtimes" tab i had to check the jdk1.7 option. nothing appeared on the left even after i hit "apply". the issue went away though which is why i still think this answer is important of the specific "project facets" related issue. after you hit ok if you come back to "project facets" you will notice java shows up as version 1.7 so you can now select it to make sure the project is "marked" as a java project. i also needed to right click on the project and select maven|update project.

score:442

if 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, select it, look for the java facet on the list, choose which version you want to use for the project and apply.

project factes - java version


Related Query

More Query from same tag