Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven is not using Java 11 - Fatal error compiling: invalid target release: 11

People also ask

How do I fix an invalid target release?

Invalid target release: 1.8 In order to solve this error either change your target to match with the Java version, your JAVA_HOME variable is referring to or install a new JDK and updated the JAVA_HOME variable.

Does Maven support Java 17?

In case of Maven, we specify the compiler plugin to use Maven with Java 17. The next step is to basically upgrade the dependencies of our application.


Seems like you're having the JAVA_HOME set in your mvn.bat. It could be pointing to the older version of Java (i.e. 8 in your case).

set JAVA_HOME=C:\path\to\jdk11 try using it on the first line, before calling maven.


Experiencing this issue while trying to deploy Spring Boot application to Heroku.

My JAVA_HOME was set correctly but was still receiving same error.

But then this worked for me:

In your pom.xml add or adapt to your own context:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin>

If other people are having this same problem but with Eclipse, (I know OP was referring to IntelliJ IDEA) also check the JRE in use for Maven:

  • Run configurations...
  • Select your Maven Build configuration
  • Click the JRE tab and choose the JRE version in accordance with your POM.