Error "Source option 5 is no longer supported. Use 6 or later" on Maven compile

Solution 1:

What helped me was these lines in pom.xml file

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

Solution 2:

Also in one of my projects, in addition to all of answers above, another try works: Just change Language level in Modules section of Project Structure [image below] [Language Level]1

Solution 3:

I had same issue, the problem is with properties. Check your JavaSE version in your project, it will be displayed beside JRE System Library folder in your project. If it is 1.5, then it will throw an error. Most probably you will have a updated version, so check the version and update it. I have updated it below based on your code.

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

Solution 4:

I think you have wrong your pom.xml:

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

change to:

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

Now depending if you are using the command line use:

mvn clean compile

or either way(eclipse ide)

Right click on project Run with maven>build>Goal (compile)

Solution 5:

I had same issue and i have added below configuration in pom.xml and it works.

<build>
   <plugins>
   <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
   </plugins>
   </build>