Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 272
helloApp Avatar asked Sep 28 '20 06:09

helloApp


Video Answer


2 Answers

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

like image 163
Hai Nguyen Avatar answered Sep 28 '22 04:09

Hai Nguyen


Please check your JDK 11 Setup in IntelliJ! Even though the project SDK is called 11, it still says that your java-version is 1.8.161. Judging from this it looks like your new jdk 11 still points to your old 1.8 installation which does not now about version 11 yet.

like image 20
meaningqo Avatar answered Sep 28 '22 02:09

meaningqo