In this tutorial, learn how to fix Intellij – Maven projects – Java release Version is not supported and Java language level errors.
We recently built a new Maven project in Intellij Idea 2019 and when we tried to compile it, we received the error shown below.
The following was the error message: Error:java: error: release version 5 not supported. There could be a variety of other concerns, such as the inability to use java:string in switches, the lack of support for the java:diamond operator in -source 1.5, and so on.
What is the issue
This occurs because Maven defaults to Java 1.5, which is a fairly outdated version. On the Maven webpage, it says:
“Apache Maven Compiler Plugin
The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.
Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler.”
To resolve the problem, we must specify the Java version to be utilized.
How To Fix Java release version is not supported error in IntelliJ IDEA Maven project
What we need to do, according to the Maven website, is add the following lines of code to the pom.xml file. I chose Java version 16 as the source and target, but you should use the version of Java that you are running.
This is what your pom.xml file should look like:
<?xml version=”1.0″ encoding=”UTF-8″?>
<groupId>your project group ID</groupId>
<artifactId>your project artifact ID</artifactId>
You can find out the version of Java you’re running in Intellij by heading to File -> Project Structure and then Project settings, Project, as shown in the screenshot below.
If you’ve any queries, check this video:
That’s all there is to it; have fun coding.