Buiding Hadoop with Eclipse / Maven - Missing artifact jdk.tools:jdk.tools:jar:1.6

JavaMavenMaven 2HadoopCloudera

Java Problem Overview


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?

Java Solutions


Solution 1 - Java

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 2 - Java

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 3 - Java

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 - Java

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 - Java

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>

Solution 6 - Java

I use below in my MR project.

<exclusions>
				<exclusion>
					<artifactId>jdk.tools</artifactId>
					<groupId>jdk.tools</groupId>
				</exclusion>
</exclusions>

Solution 7 - Java

maybe system install jdk package, but maybe some devel tools or plugin.

I find this problem under opensuse env. and I install java-1_6_0-openjdk-devel

the problem is disppeared..

Solution 8 - Java

I also faced this problem because I just only installed JRE not with JDK. So , adding dependency for jdk.tools can't fix for me because tools.jar was not exist at my ${JAVA_HOME}/lib/ directory.

Now I downloaded and installed JDK to fix it.

Solution 9 - Java

Change the set of installed JREs in your eclipse. Window > Preferences > Java > Installed JREs, change the location of jre to %JAVA_HOME%/jre, but not something like C:\Program Files\Java\jre7

Solution 10 - Java

If the jdk.tools is present in the .m2 repository. Still you get the error something like this:

missing artifact: jdk.tools.....c:.../jre/..

In the buildpath->configure build path-->Libraries.Just change JRE system library from JRE to JDK.

Solution 11 - Java

try :

mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dversion=1.6 -Dpackaging=jar -Dfile="C:\Program Files\Java\jdk\lib\tools.jar"

also check : http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Solution 12 - Java

Ok, if you are using Windows OS

  1. Go to C:\Program Files\Java\jdk1.8.0_40\lib (jdk Version might be different for you)

  2. Make sure tools.jar is present (otherwise download it)

  3. Copy this path "C:\Program Files\Java\jdk1.8.0_40"

  4. In pom.xml

     <dependency>
     <groupId>jdk.tools</groupId>
     <artifactId>jdk.tools</artifactId>
     <version>1.8.0_40</version>
     <scope>system</scope>
     <systemPath>C:/Program Files/Java/jdk1.8.0_40/lib/tools.jar</systemPath>
     </dependency>
    
  5. Rebuild and run! BINGO!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjvatamanView Question on Stackoverflow
Solution 1 - JavarustyxView Answer on Stackoverflow
Solution 2 - JavanpeView Answer on Stackoverflow
Solution 3 - JavajvatamanView Answer on Stackoverflow
Solution 4 - JavaAdam LaStrangeView Answer on Stackoverflow
Solution 5 - JavaRavi MachaView Answer on Stackoverflow
Solution 6 - JavaSumanView Answer on Stackoverflow
Solution 7 - Javaliuyang1View Answer on Stackoverflow
Solution 8 - JavaCataclysmView Answer on Stackoverflow
Solution 9 - JavaSondy WooView Answer on Stackoverflow
Solution 10 - JavaDivya RakshuView Answer on Stackoverflow
Solution 11 - JavaYogesh BorkhadeView Answer on Stackoverflow
Solution 12 - JavaLokeshView Answer on Stackoverflow