close

[Solved] Maven: Invalid target release: 10

Hello Guys, How are you all? Hope You all Are Fine. Today I am facing the following error Maven: Invalid target release: 10 in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Maven: Invalid target release: 10 Error Occurs?

Today I am facing the following error Maven: Invalid target release: 10 in Java.

How To Solve Maven: Invalid target release: 10 Error ?

  1. How To Solve Maven: Invalid target release: 10 Error ?

    To Solve Maven: Invalid target release: 10 Error My source and destination java version in maven-compiler-plugin were 11, java -version was also on version 11, but my JAVA_HOME was pointing to JDK-1.8.

  2. Maven: Invalid target release: 10

    To Solve Maven: Invalid target release: 10 Error My source and destination java version in maven-compiler-plugin were 11, java -version was also on version 11, but my JAVA_HOME was pointing to JDK-1.8.

Solution 1


This worked for me:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <release>10</release>
            </configuration>
        </plugin>
    </plugins>
</build>

This answer says you need:

<dependencies>
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>6.2</version> <!-- Use newer version of ASM -->
    </dependency>
</dependencies>

inside the <plugin/> tag, but the newer mvn (3.5.4) must obviate that, since I didn’t need it.

Solution 2

Same problem fixed for me by setting JAVA_HOME environment variable to point to the JDK with right version.

My source and destination java version in maven-compiler-plugin were 11, java -version was also on version 11, but my JAVA_HOME was pointing to JDK-1.8.

Check JAVA_HOME again by using a terminal instead of IDE:

Linux:
echo $JAVA_HOME

Win:
echo %JAVA_HOME%

Then Build your project in the same terminal:

mvn clean package

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read