Buiding Hadoop with Eclipse / Maven - Missing artifact jdk.tools:jdk.tools:jar:1.6
Solution 1
jdk.tools:jdk.tools
(or com.sun:tools
, or whatever you name it) is a JAR file that is distributed with JDK. Usually you add it to maven projects like this:
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
See, the Maven FAQ for adding dependencies to tools.jar
Or, you can manually install tools.jar
in the local repository using:
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.6 -Dfile=tools.jar -DgeneratePom=true
and then reference it like Cloudera did, using:
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.6</version>
</dependency>
Solution 2
The problem is in the Eclipse Maven support, the related question is here.
Under Eclipse, the java.home
variable is set to the JRE that was used to start Eclipse, not the build JRE. The default system JRE from C:\Program Files
doesn't include the JDK so tools.jar
is not being found.
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
Then refresh the Maven dependencies (Alt-F5) (Just refreshing the project isn't sufficient).
Solution 3
thanks to npe, adding
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_05</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
to pom.xml did the trick.
Solution 4
If you can live without tools.jar and it's only included as a chained dependency, you can exclude it from the offending project:
<dependency>
<groupId>org.apache.ambari</groupId>
<artifactId>ambari-metrics-common</artifactId>
<version>2.1.0.0</version>
<exclusions>
<exclusion>
<artifactId>jdk.tools</artifactId>
<groupId>jdk.tools</groupId>
</exclusion>
</exclusions>
</dependency>
Solution 5
This worked for me:
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_05</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
jvataman
Updated on July 05, 2022Comments
-
jvataman almost 2 years
I am trying to import cloudera's org.apache.hadoop:hadoop-client:2.0.0-cdh4.0.0 from cdh4 maven repo in a maven project in eclipse 3.81, m2e plugin, with oracle's jdk 1.7.0_05 on win7 using
<dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>2.0.0-cdh4.0.0</version> </dependency>
however, I get the following error:
The container 'Maven Dependencies' references non existing library 'C:\Users\MyUserId\.m2\repository\jdk\tools\jdk.tools\1.6\jdk.tools-1.6.jar'
more specific, maven states that the following artifact is missing
Missing artifact jdk.tools:jdk.tools:jar:1.6
How to solve this?
-
Dan W over 11 yearsMight want to add that your maven command needs to be ran from your jdk(version 6)/lib folder.
-
Daniel Fernández almost 10 yearsThanks. Just a small comment for readers: remember that line break between
-vm
and the actual parameter value is required. -
Alex over 9 yearsJust had this occur where Eclipse was auto detecting the
[jdk]\jre\bin\javaw.exe
, and when run like this, Maven is unable to locate the tools.jar. Needed to explicitly change Eclipse to run using[jdk]\bin\javaw.exe
for Maven to properly find what it calls thecom.sun:tools:1.8
jar -
user 923227 about 9 yearsFor the absolute path on windows: the std backslash needs to be replaced by fwd slash - C:/Program Files/Java/jdk1.7.0_67/lib/tools.jar
-
Alex almost 9 yearsnever add that in your pom if you work with other people :)
-
David Lotts almost 9 yearsI have to emphasize what @Alex says: use the JDK bin, not the JRE bin for the
-vm
in the eclipse.ini. @rustyx shows shows the path to the [jdk_path]/ jre /bin and for me, that is what caused my failure of not finding tools.jar -- although I pointed to javaw.exe, not the dll. When I changed it toC:/Program Files/Java/jdk1.8.0_51/bin/javaw.exe
and started eclipse, Alt-F5, and the error went away. I was surprised to learn there are two different javaw executables, with different check-sums in the JDK. -
rustyx almost 9 years
-
abhijitcaps over 8 yearsThis is great..but the mvn install command was giving me build failure.. Adding quotes for the attributes worked for me..
-
npe over 8 years@abhijitcaps If you're referring to
tools.jar
by it's full path in Program Files, then this path contains spaces and has to be wrapped with quotes, yes. It's easier to just navigate to that directory and runmvn install:install-file
from there ;) -
icyitscold over 8 yearsThe 45 people who hit this m2e bug should vote on it in the eclispe bug tracker - bugs.eclipse.org/bugs/show_bug.cgi?id=432992
-
loesak over 8 yearsit should be mentioned that you dont need to modify the eclipse.ini but have the choice to modify your JAVA_HOME environment variable in the OS to point to the jdk's jre. this fixed the issue for me after restarting eclipse.
-
somnathchakrabarti about 7 yearsDid a "Maven --> Update Project ... " after adding the vm entry and the error disappeared from pom.xml
-
Yogesh Borkhade almost 7 yearstry : - - mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dversion=1.6 -Dpackaging=jar -Dfile="C:\Program Files\Java\jdk\lib\tools.jar" or check maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
-
leeyuiwah about 5 yearsFive years after the answer in the other SO Q&A (stackoverflow.com/a/23129154/1168041) this bug is still there (now is 2019-04-05). I also want to note that be very careful with the path. 1) do not use double quotes around the string. 2) Use forward slash even in windows. 3) Use the jvm.dll 4) make sure you point to
jdk.../jre/...
. 5) as @Daniel Fernández has pointed out, need a line break after -vm (and not --vm!) For me the winning path is thisC:/Program Files/Java/jdk1.8.0_201/jre/bin/server/jvm.dll
-
prashanth-g about 5 yearsThis really helped me!.
-
MikeKulls over 4 yearsThis doesn't explain where to put this
-
Alessandro S. about 2 yearsWhat does precisely mean "you can live without tools.jar"? How can one be sure it's safe to remove it?