Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Maven Project "Source option 5 is no longer supported. Use 6 or later."

I'm following a PluralSight course, "Spring Framework: Spring Fundamentals" by Bryan Hansen. I've followed the demo precisely (I believe) but am getting the error message "Error:java: Source option 5 is no longer supported. Use 6 or later.".

I'm using the latest version of IntelliJ, with the following configurations:

  • Under "Preferences > Build, Execution, Deployment > Compiler > Java Compiler" I have the project bytecode version set to Java 11 and the per-module bytecode version to "Same as language level".
  • Under "File > Project Structure > Project" I have the project SDK set to 11 and project language level set to 11 as well.
  • Have my pom.xml with the following build settings:

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

I've looked at some other similar posts, and they seem to sometimes have the above configuration as 1.6 instead of 11, but I'm trying to follow this tutorial closely. Am still curious as to the discrepancy here.

Not sure what's casuing this error to be thrown, as far as I can tell I've got everything set up correctly but clearly that's not the case. Any help would be appreciated.

like image 854
SpartanHedgey Avatar asked Jan 10 '20 16:01

SpartanHedgey


People also ask

How do you fix source Option 5 is no longer supported use 6 or later?

Right click on Project > Maven > Update the project. Right click on Project > Run As > Maven install -- The pom. xml file is running and java jars are download and installed to project.

What is source 5 no longer supported?

The error (Source option 5 is no longer supported) is common when we create a Maven project from the old archetypes. In this case, we need to specify the source and target version to the Maven compiler. We can specify these properties in Maven pom. xml file.

What is source option?

The source options modify the way the compiler treats the physical source files.

Does Maven work with Java 11?

Chances are that it just runs fine with Java 11. Hint: You can speed up multi-module Maven projects by using parallel builds, e.g. mvn -T 4 compile compiles all modules in parallel on 4 CPU cores.


1 Answers

Fixed this by doing the following.

Project Structure > Modules (under Project Settings) > Set language level to 11

Hope this helps someone who runs in to the same issue.

like image 119
SpartanHedgey Avatar answered Oct 23 '22 09:10

SpartanHedgey