Maven build error invalid target release: 17


We recently upgraded our Java version in our Project from Java 8 to Java 17. Now everytime I try to do a maven build it shows me below error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin 3.5.6:compile (default-compile) on project spring-boot-hello: Fatal error compiling: error: invalid target release: 17 [Help 1]

Also I already downloaded JDK 17 in my system. Here is my java version:

java -version openjdk version "17" 2021-09-14 OpenJDK Runtime Environment Homebrew(build 17+0) OpenJDK 64-Bit Server VM Homebrew(build 17+0, mixed mode, sharing)


Check maven version by running below command, it will help you to identify what java version maven is using.

mvn -version Apache Maven 3.8.1 (ff8e977a158738155dc465c6a97ffaf31982d739) Maven home: /usr/local/Cellar/maven/3.8.3/libexec Java version: 11.0.10, vendor: Oracle Corporation, runtime: /usr/local/Cellar/openjdk@11/11.0.10/libexec/openjdk.jdk/Contents/Home Default locale: en_MY, platform encoding: UTF-8 OS name: "mac os x", version: "11.6", arch: "x86_64", family: "mac"

As you can see above, maven is using 11.0.10 java version. So we need to fix this.

Basically maven tries to pick the Java version specified in location JAVA_HOME. So check what value you have set by running below command-


If it shows any other java version other than 17. Then change your JAVA_HOME path in Environment variables to point it to JDK 17. Refer this article on How to change JAVA_HOME in Environment Variable

Once above steps are done. Rebuild your project using maven. It should not throw any error now.




Hot Deals ends in

Technical Quizzes Specially For You:


Search Tags

    invalid target release 17 maven error

    maven error solution invalid target release