Eclipse JAX-RS (REST Web Services) 2.0 requires Java 1.6 or newer

Maven projects come with a bunch of plugins applied implicitly to the build. One of them being the maven-compiler-plugin. Unfortunately the Java version for the plugin defaults to 1.5. Most Maven project you see will override the Java version simply by declaring the plugin (in your pom.xml file) and configuring the Java version

  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
  </build>

Eclipse (with m2e plugin) will set the compiler compliance level to the setting in the plugin. You can view this by going to

Right click on the project -> properties -> Java Compiler -> Look at compliance level

UPDATE

Instead of the above compiler plugin configuration, you can also simply just do

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

The default plugin configuration will look for these properties. It's a lot less verbose than re-declaring the plugin.

After adding the properties or the compiler plugin to your pom.xml, you might need to update the project. See Manish's answer.


those who are doing with properties way and if it is not working do this step.
in Pom.xml

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

After that do this:

  project folder-> maven--> update project--> check force update-->ok

After that do

 project folder-->run as-->mvn build with goal eclipse:eclipse

you don't need to re-import the project as suggested in other answer/


I know the topic is old but I had the same problem and it's hard to find informations on it. So set the properties wasn't enough for me, I had also to delete the project from Eclipse, then delete the .project file and reimport the project as a Maven project (even if I created it as a Maven project already) like it is answer on this topic.