Parent POM for Java 8 development

Hey guys!

I’m currently developing a plugin where I want to use .
Unfortunately it needs at least java 1.7. So I decided to switch to java 1.8.

However, my build always fails:

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

This is my pom.xml:

Any suggestions are welcome :slight_smile:


Your POM parent is fine. It sets scijava.jvm.version to 1.8.

You can confirm this using:

mvn help:effective-pom | grep scijava.jvm.version

The issue is that your Maven itself is using a too-old version of Java. That’s what “invalid target release: 1.8” means: javac does not know how to compile for version 1.8 because it is an older version than 1.8.

Follow-up questions:

  • What does mvn -v say?
  • What does java -version say?
  • What does javac -version say?
  • What is your JAVA_HOME set to?
  • What OS are you running? If Linux, you can use update-java-alternatives to change Java versions.

Other suggestions:

  • Do not include the bedatadriven repo; instead, use imagej.public group as normal. That will inherit the Renjin artifacts, thanks to the ImageJ Maven repository’s proxying feature.
  • Do not configure the maven-compiler-plugin; the configuration is already set to 1.8 in the parent.
  • Do not use javax.vecmath:vecmath; instead, use org.scijava:vecmath.
  • Do not specify <version> elements for artifacts managed in the parent POM structure.
1 Like

Dear curtis,

thanks for your answer. I followed most of your suggestions. Here is the most recent POM:

What does mvn -v say?

Apache Maven 3.3.9 (NON-CANONICAL_2015-11-23T13:17:27+03:00_root; 2015-11-23T11:17:27+01:00) Maven home: /opt/maven Java version: 1.8.0_92, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk/jre Default locale: de_DE, platform encoding: UTF-8 OS name: "linux", version: "4.5.4-1-arch", arch: "amd64", family: "unix"

java -version

openjdk version "1.8.0_92" OpenJDK Runtime Environment (build 1.8.0_92-b14) OpenJDK 64-Bit Server VM (build 25.92-b14, mixed mode)

What does javac -version say?

javac 1.8.0_92

What is your JAVA_HOME set to?

It isn’t set. I changed it by export JAVA_HOME=/usr/lib/jvm/java-8-openjdk/bin/java
but that does not help.

What OS are you running? If Linux, you can use update-java-alternatives to change Java versions.


OK, I’ve found a solution. In eclipse I have to select:
Window -> Preferences -> Java -> Installed JRES
Then select java-8-openjdk, press edit and add

to the default VM arguments.

1 Like

Whoa, I’ve never heard of that. How did you figure that out? Do you think this issue will affect others? Should we document it somewhere on the wiki?

Also: didn’t realize you were getting that error from Eclipse, as opposed to the CLI. Does it build on the CLI using mvn?

I changed my project compiler to jdk-8 and then get the error message:

-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.

I found the solution for that problem on stackoverflow.

It does build on the CLI using mvn.