Maven and Gradle "invalid target release1.8"

Your code is working fine on one laptop, but when you clone, and try and get working on another laptop, you get the following error from a gradle, or mvn compile:

“invalid target release1.8”

**You need to change your JAVA_HOME to point at JDK 1.8:**

$ mvn compile [INFO] Scanning for projects… [INFO] [INFO] ———————————————————————— [INFO] Building project 0.0.1-SNAPSHOT [INFO] ———————————————————————— [INFO] [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ project — [INFO] Using ‘UTF-8’ encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 0 resource [INFO] [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @  — [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to java/workspace/project/target/classes [INFO] ———————————————————————— [INFO] BUILD FAILURE [INFO] ———————————————————————— [INFO] Total time: 1.454 s [INFO] Finished at: 2016-04-15T16:36:37+01:00 [INFO] Final Memory: 13M/246M [INFO] ———————————————————————— [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project project: Fatal error compiling: invalid target release: 1.8 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

$ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

$ JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home

$ mvn compile Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0 [INFO] Scanning for projects… [INFO] [INFO] ———————————————————————— [INFO] Building project 0.0.1-SNAPSHOT [INFO] ———————————————————————— [INFO] [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ project — [INFO] Using ‘UTF-8’ encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 0 resource [INFO] [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ project — [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to java/workspace/project/target/classes [INFO] ———————————————————————— [INFO] BUILD SUCCESS [INFO] ———————————————————————— [INFO] Total time: 1.898 s [INFO] Finished at: 2016-04-15T16:38:49+01:00 [INFO] Final Memory: 20M/309M [INFO] ————————————————————————

mvn compile is successful

Author | Miles Davenport

Career programmer, who designs, assembles, fixes, and supports customers, software and systems.