HappyCoding HappyCoding - 5 months ago 69
Java Question

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>

Answer

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