Sunday, December 10, 2017

Maven build failed with "Fatal error compiling: invalid target release: 1.8 -> [Help 1]"

The below build failed error popped-up  when I try to build (use mvn clean install) the project with Maven.

Error log:

INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
INFO] ------------------------------------------------------------------------
INFO] Total time: 3.390 s
INFO] Finished at: 2017-12-09T16:33:24+05:30
INFO] Final Memory: 9M/150M
INFO] ------------------------------------------------------------------------
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2
:compile (default-compile) on project dpc-portal: Fatal error compiling: invalid
 target release: 1.8 -> [Help 1]
ERROR]

The reason was, I set JAVA_HOME to the JDK 1.7 (as in below image) but try to build using JDK 1.8. So after change the JAVA_HOME to JDK 1.8 version, project was built successfully.



Reference:
https://stackoverflow.com/questions/28291691/fatal-error-compiling-invalid-target-release-1-8-help-1