• May 21, 2022

[Fix] Git Bash Java: invalid target release: 11

So recently I set up a Quarkus project to build some APIs on my new computer, which had JDK 8 installed. When I ran the command:

./mvnw quarkus:dev

I got the following error:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.848 s
[INFO] Finished at: 2021-05-20T23:28:45+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project
 quarkus-events: Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

In short, the error complained that in the pom.xml file, I set the target release to version 11:


However, Maven couldn’t find JDK version 11 on my system. Thus, it produced the error.

Setting environment variable doesn’t work!

I’ve tried changing the SDK to version 11 in Windows’ system environment and also user’s environment variable. However, when checking the java version in Git bash, the JDK is still 1.8.

How to fix invalid target release: 11?

It turned out, that the fix is quite simple. All you need to do is to set the environment variable to JDK 11 in ~/.bashrc file!

So, here is the line you need to put in ~/.bashrc:

export JAVA_HOME='/c/Program Files/Java/jdk-11.0.11'

Make sure you replace the path with your own JDK.

Save the file and reload the settings by executing:

source ~/.bashrc

After that, your build should work:

Leave a Reply

Your email address will not be published.