Maven not picking JAVA_HOME correctly

It's a bug in the Eclipse Maven support. Eclipse doesn't support all of the global Maven properties as per the Maven specs.

According to the specs:

${java.home} specifies the path to the current JRE_HOME environment use with relative paths to get for example

At least in Eclipse 4.3.1 that is not the case, here java.home always points to the JRE that was used to launch Eclipse, not the build JRE.

To fix the issue you need to start Eclipse using the JRE from the JDK by adding something like this to eclipse.ini (before -vmargs!):

-vm
C:/<your_path_to_jdk170>/jre/bin/server/jvm.dll

You should NEVER use system scope dependencies. All the code in tools.jar will be available just via the running JVM already. You should remove this dependency altogether..

Also in order to check what runtime Maven is using just call

mvn -v

If you are still having a dependency to the tools jar as a problem, one of the dependencies you added has that dependency (and it is really bad quality). To find out which one it is run

mvn dependency:tree

or if that fails just remove one dependency after another until the problems is gone for the command above.

Then, when you know where it comes from you can decide what to do next. One path would be to use an exclusion on the dependency that pull tools in.


It seems your JAVA_HOME is set to point to the JRE in eclipse.