20

I have Java version 1.8.111 installed and the initial error message after running mvn3 install was as below.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project myfile: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ vendor='sun' version='1.6' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.

To resolved this, I've updated my toolchains.xml to version 1.8.111 but still getting the same error. I've also tried after running mvn3 clean and successfully cleaned but still getting the same error.

Could anyone pinpoint where this version 1.6 is fetched from? I checked JAVA_HOME already, it's set to 1.8.

Can anyone explain how maven calls Java version?

Appreciate your help.

Below is my toolchains.xml enter image description here

cb4
  • 6,689
  • 7
  • 45
  • 57
haeminish
  • 988
  • 5
  • 15
  • 29
  • 1
    I believe that your are interpreting the error message in the wrong way. To me it seems that the project you are trying to build requires a JDK 1.6.x to build. To test for this you could edit your toolchains.xml to tell maven to use your JDK 1.8 as a toolchain for JDK 1.6 – Thomas Kläger Nov 01 '16 at 07:00
  • Can you post your `~/.m2/toolchains.xml` file? – Tunaki Nov 01 '16 at 11:59
  • How should it be interpreted? Could you explain what that error message is saying? – haeminish Nov 02 '16 at 00:06

1 Answers1

25

Your application is expected to be built with JDK 1.6 and to locate it Maven is looking for definition of [ vendor='sun' version='1.6' ] within toolchains.xml in your {home}/.m2/ directory (see eg this maven guide). You just need to point to it and all should be good.

<?xml version="1.0" encoding="UTF8"?>
<toolchains>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.6</version>
      <vendor>sun</vendor>
    </provides>
    <configuration>
       <jdkHome>/Library/Java/JavaVirtualMachines/jdk1.6.X_XX.jdk/Contents/Home</jdkHome>
    </configuration>
  </toolchain>
</toolchains>
MartinMlima
  • 1,736
  • 1
  • 12
  • 13
gerasoras
  • 621
  • 6
  • 10