Blog4Java

A personal and Java blog, likely only for me

Try to avoid copy-paste. Fatal error compiling: invalid target release: 1.8.0_11

| 0 comments

Bazinga!

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

To summarize, I want to compile a maven project using Java 8, that is possible thanks to the JAVA_HOME configuration:

But I copied the maven compiler plugin configuration from another maven project without putting special attention:

In programming the error usually contains the solution. I’m trying to use the current Java version (1.8.0_11) as the option for the javac command, that is not the expected one.

${java.version} is a environment variable whose value is currently 1.8.0_11, but the Maven Compiler Plugin expects the standard options of the javac command for Setting the -source and -target of the Java Compiler.

That is:

  • 1.3 for Java SE 1.3
  • 1.4 for Java SE 1.4
  • 1.5 for Java SE 5
  • 5 synonym for 1.5
  • 1.6 for Java SE 6
  • 6 synonym for 1.6
  • 1.7 the default value. The compiler accepts code with features introduced in Java SE 7. (Yes, as it appears in the Java 8 official documentation)
  • 7 Synonym for 1.7

Actually I only use the values with the format 1.X, that includes 1.8, that I assume is the default value for Java 8 SE.

Why did I use this variable?

Because in my previous project it wasn’t an environment variable, but a custom property in the pom.xml:

But this time I have another two custom properties:

Thus the solution is easy:

  1. Try to not copy-paste
  2. Pay attention in any case
  3. Just use the appropriate variables

Author: Javier (@jbbarquero)

Java EE developer, swim addict, occasional videogames player, fan of Ben Alex and Shamus Young, and deeply in love with my wife. Sooner or later I'll dedicate a post to expand this simple introduction.

Leave a Reply

Required fields are marked *.