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

We Are Going To Discuss About Maven is not using Java 11 – Fatal error compiling: invalid target release: 11. So lets Start this Java Article.

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

1. Maven is not using Java 11 – Fatal error compiling: invalid target release: 11

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.

2. Maven is not using Java 11 – Fatal error compiling: invalid target release: 11

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.

## Solution 1

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.

Original Author Of This Content

## Solution 2

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:

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


Original Author Of This Content

## Solution 3

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.

Original Author Of This Content

## Solution 4

I was facing the same problem. Setting JAVA_HOME environment variable to the right JDK solved my problem.

java -version was showing the right version, but echo %JAVA_HOME% pointed to the wrong JDK. Fixing it, solved this issue for me.

Original Author Of This Content

## Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.