Java 11 : Error:java: invalid source release: 11 – Not sure what to do anymore

javajava-11java-8maven

Hello so i have upgraded from java 8 to java 11 and i get this error no matter what.I am using intellij and windows 10.
What i have changed to 11:
1)In Project Structure -> Project:
enter image description here

2)Project Structure ->Modules
enter image description here

3)My compiler module Target bytecode version is set to 11 aswell in settings->Build,Execution,Deployment -> Java Compiler.

I even changed Both environment variables respectiveley the JAVA_HOME in user variables and JAVA_HOME in system variables to jdk-11.0.8.

When i run java -version and javac -version both show that i have version 11 installed.
When i try running a mvn clean package it always fails with this error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project abc: Fatal error compiling: invalid
target release: 11 -> [Help 1]

Please help me fix the error,
Any help would be greatly appreciated !

L.EThis is part of the project pom

<plugin>
                <inherited>true</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <optimize>true</optimize>
                    <encoding>UTF-8</encoding>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                    <compilerArguments>
                        <parameters/>
                    </compilerArguments>
                </configuration>

I have also added <release>11</release> <!--or <release>10</release>--> to it but same issue remains.

Best Answer

IntelliJ IDEA 2021.1.3 (Community Edition)

If you are using Gradle build tool:

File | Settings | Build, Execution, Deployment | Build Tools | Gradle

Choose your project and choose Gradle JVM version 11. enter image description here