Search code examples
mavenjava-8maven-pluginjava-17

error: invalid source release: 1.17 whiling using openJDK17 to build


I updated the maven.compiler.target and maven.compiler.source of my maven project from both 1.8 to 1.17 and I also updated my JDK to openjdk version "17.0.6" 2023-01-17.

I confirm my maven version is also using jdk17 by running mvn -v.

Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: /usr/local/Cellar/maven/3.9.0/libexec
Java version: 17.0.6, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.6/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "12.6.3", arch: "x86_64", family: "mac"

But I am still seeing this error invalid source release: 1.17. Is there anything I should check?

BTW, I do not see this error if my maven.compiler.target and maven.compiler.source are both 1.8 while using the JDK17 to compile.

Thank you.


Solution

  • The versioning for java has changed after version 1.8. The newer versions are without 1.

    So your version must be 17.

    <maven.compiler.target>17</maven.compiler.target>  
    <maven.compiler.source>17</maven.compiler.source>