Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Compilation Error: Fatal error compiling: invalid target release: 1.8

Similar problem as posted in Fatal error compiling: invalid target release: 1.8 -> [Help 1] However, problem is not solved after I check my settings with the solutions. Details is as follows.

Maven Error Message is:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project: Fatal error compiling: invalid target release: 1.8 -> [Help 1]

My JAVA_HOME setting is:

C:\Program Files\Java\jdk1.8.0_40

Java -version:

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

I've added compilation detail to pom.

  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.2</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
like image 433
HappyCoding Avatar asked Apr 09 '15 02:04

HappyCoding


People also ask

How do I fix an invalid target release?

Fix invalid target release error by changing Maven's Java version. You need to install a newer JDK and then update JAVA_HOME or PATH environment variables.

What is fatal error compiling?

The problem is that there is mismatch in the Java/JDK versions. The project is trying to use a particular Java version to build the project. However, the system doesn't support the Java version the project is intended to build upon. First things first, decide on which Java/JDK version you want to use.

Does Maven work with Java 17?

In case of Maven, we specify the compiler plugin to use Maven with Java 17. The next step is to basically upgrade the dependencies of our application.


2 Answers

As discussed in comments, You need to restart your console after setting your %JAVA_HOME% enviroment variable.

like image 109
Jorge Campos Avatar answered Oct 06 '22 00:10

Jorge Campos


Eclipse Users, Cross check your run configuration in Maven build. Follow steps to correct -

  1. "Run Configuration"
  2. Under "Maven Build", Select configuration you are using
  3. Click on "JRE" tab
  4. Select Correct JAVA Version

This solution works for me!

like image 25
Narendra Chandratre Avatar answered Oct 06 '22 01:10

Narendra Chandratre