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.


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.


You can also edit the <ProjectName>.iml file (it is created automatically in your project folder if you're using IntelliJ) directly by changing the following line,

From: <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">

To: <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">

As your approach is also meaning to edit this file. :)


I am following the Jenkov tutorial Your First Maven Project and got the same error when attempting to execute the command mvn package. In this tutorial we are not using an IDE, but instead are working at the CLI, and have only a pom.xml and a HelloWorld.java file, both of which can be made with a simple text editor like Notepad.

I don't fully understand, but I think the error message is referring to the version of Java that is being invoked. If this was the intention, the error message certainly could have been better crafted! Hopefully someone will correct me if I am wrong.

Maybe related, I've noticed that certain operations on my system default to assuming Java 1.5, even though this version of Java isn't installed on my PC. (For example, when creating a new Maven project in Eclipse.)

In any event, specifying a java version that is 7 or later explicitly seems to be the answer. I have Java 15 on my laptop, so I specified the Java 15 version of Java by adding the following to the pom.xml.

<properties>
    <java.version>15</java.version>
    <maven.compiler.source>15</maven.compiler.source>
    <maven.compiler.target>15</maven.compiler.target>
</properties>

However, I also tried specifying 1.7 or 1.8, and these worked as well.

EDIT: Since writing this post, I've read that Maven defaults to Java 1.5 if a version is not specified, but I can't recall where I read this and can't find a point in the Maven documentation about this.