IntelliJ Error: Release version 5 not supported

I’m having difficulty running a simple Java Maven project in IntelliJ IDEA Ultimate 2019.3.1. When I try, I get the error Error:java: error: release version 5 not supported.

Terminal output for java --version is:

openjdk 11.0.5 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.1, mixed mode, sharing)

and for javac --version is:

javac 11.0.5

In the IntelliJ settings for the Java Compiler, the “Target bytecode version” is set to 1.8, but this results in a series of errors when trying to run the project. Changing the version to 1.11 results in the error Error:java: Source option 5 is no longer supported. Use 6 or later.. What could be the issue and how can I solve it?

The issue is that the project is trying to use Java version 5, which is not supported by the version of Java being used. To solve the issue, update the Maven compiler plugin version to at least 3.8.1 in the pom.xml file of the project. This can be done by adding the following code to the build section of the pom.xml file:

<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>

This will set the source and target versions of the project to 11, which is compatible with the version of Java being used.