Build error: missing artifact com.sun:tools:jar:1.6
Asked Answered
H

16

16

Trying to build PlayN sample projects I get:

Missing artifact com.sun:tools:jar:1.6  pom.xml /playn-cute line 6  Maven Dependency Problem

On every pom.xml file. How do I resolve it?

Edit:

I've added the profiles node to the pom.xml, but the error remains. I've checked the tools.jar is actually exists, and it didn't. So I've added tools.jar to lib folder. And still the error remains.

The full pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.googlecode.playn</groupId>
        <artifactId>playn-project</artifactId>
        <version>1.0.1</version>
    </parent>

    <artifactId>playn-cute</artifactId>
    <name>PlayN Cute Metaproject</name>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <playn.version>1.0.1</playn.version>
    </properties>

    <modules>
        <module>core</module>
        <module>java</module>
        <module>html</module>
        <!-- <module>flash</module> -->
        <module>android</module>
    </modules>

    <profiles>
        <profile>
            <id>default-tools.jar</id>
            <activation>
                <property>
                    <name>java.vendor</name>
                    <value>Sun Microsystems Inc.</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.6</version>
                    <scope>system</scope>
                    <systemPath>${java.home}/../lib/tools.jar</systemPath>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
Heiser answered 1/1, 2012 at 17:3 Comment(4)
What OS are you using? What is the exact path to your javac command and what is the exact path at which you installed the tools.jar? Do you have the Java SDK installed or just the Java JRE? It sounds like you have the latter, but you need the former.Hellenistic
Check my answer in more or less the same issue : I think it has to do with the path used for the tools.jarPatriliny
Quick solution which helped me was to point the JRE to the one available in the JDK folder.Therrien
Does this answer your question? Missing artifact com.sun:tools:jarMihe
C
23

This artifact is always handled as a 'system' dependency. It is never stored in a repo.

See https://web.archive.org/web/20151031071007/http://maven.apache.org/general.html#tools-jar-dependency for the details.

if there is no tools jar, and you aren't on a Mac, you are trying to use a JRE when the requirement is a JDK. You can't turn one into the other by copying file.

Counselor answered 1/1, 2012 at 21:29 Comment(5)
Thanks bmargulies. Please see my question edit, I've added further progress.Heiser
well I am on Mac, but how does it make my life better?Claustrophobia
Did you notice the date on this? Mac JDKs used to be shaped differently.Counselor
Link is dead :(Ap
@Ap Link is fixedInglorious
E
9

I had the same issue when using Eclipse in Windows 7, even when I removed the JRE from the list of JREs in the Eclipse settings and just had the JDK there. Your question doesn't state if you're using command-line Maven, or Eclipse, so I thought I'd share what fixed it for me in Eclipse.

What I ended up having to do was modify the command-line for the shortcut I use to launch Eclipse to add the -vm argument to it like so:

-vm "T:\Program Files\Java\jdk1.6.0_26\bin"

Of course, you would adjust that to point to the bin directory of your JDK install. What this does is cause Eclipse itself to be running using the JDK instead of JRE, and then it's able to find the tools.jar properly.

Emeryemesis answered 18/1, 2012 at 17:8 Comment(1)
This worked for me in a Maven project in eclipse but to get the full effect I had to do Maven -> Update Project from the context menuJasen
E
5

There are many reasons you might see this error on your eclipse IDE

  1. Eclipse pointing to JRE rather than JDK
  2. JDK library not containing tools.jar

For this you might want to add tools.jar by yourself through Preferences -> Java -> Installed JRE -> (select JDK, edit and add external jars -> navigate to tools.jar)

  1. Other reason might be this -> the parent maven repository of your project have a jar with the same name under some other artifactory.

You need to locate tools.jar through -> Dependency Heirarchy view for pom.xml in eclipse and once you have located the jar you can add an exclusion there

like ->

<groupId>com.parent.project</groupId>
    <artifactId>parent-project-dependencies-pom</artifactId>
    <version>${dependencies.version}</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
            </exclusion>
         </exclusions>
Equal answered 17/10, 2014 at 10:59 Comment(0)
S
3

I'm testing on Ubuntu. I'm not very familiar with Java tools. Installing JDK solved the issue for me.

aptitude install openjdk-6-jdk
Sure answered 11/3, 2012 at 1:45 Comment(0)
M
2

I also had this problem, and although the java_path was ok, the problem persisted. The fix which worked for me was:

Run this command (where Dfile points to your tools.jar):

mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile="C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar"

Then in the main pom.xml add the reference to the dependency:

<dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.4.2</version>
</dependency>
Mancy answered 24/4, 2013 at 11:15 Comment(0)
C
2

You shouldn't need to add the dependency to your POM. I had this problem in eclipse and it was because eclipse was running in a JRE, not a JDK.

See this question here for the same issue: Missing artifact com.sun:tools:jar

Resolved by specifing the vm eclipse uses. Also check the build path for your eclipse project is using a JDK, not a JRE.

Having a JDK on the build path, and explictly setting a JDK in the eclipse INI still doesn't work however if the java on the path was a jre not a jdk (windows path, or linux/mac equivilent).

Run this from the command line to see what java on your path is: How do I find where JDK is installed on my windows machine?

If its a JRE you should change it to a JDK and relaunch your IDE.

Chutzpah answered 12/11, 2014 at 10:53 Comment(0)
S
1

Some pointers that can help you:

  1. Check if the tools.jar is present in the repo url in pom.xml.
  2. Verify the dependency in pom.xml. It might be incorrect. I did not find any jar artifact at http://search.maven.org/#browse%7C96611365.

Thanks.

Subaltern answered 1/1, 2012 at 18:2 Comment(0)
I
0

this is how I resolved it. please paste below lines into your eclipse.ini file.

-vm path till java.exe (as shown below)

-vm C:/Program Files/Java/jdk1.7.0_60/bin/java

hope it helps.

Indoaryan answered 1/10, 2014 at 4:51 Comment(0)
T
0

This is how I resolved this problem using Jboss Developer Studio 8.1.10:

Add to your jbdevstudio.ini file located in: D:\Users\bertrand\jbdevstudio\studio these two lines (before -vmargs):

-vm
C:\Program Files\Java\jdk1.7.0_79\bin
Tuyettv answered 14/10, 2015 at 9:57 Comment(0)
S
0

I had the same problem, it was because of multiple tools.jar files in the path.

But the problem was specific to work-space pom dependency. I came to know this, as my other work-spaces in the same eclipse are working fine.

Steps I have taken to investigate & solve:

1) Open project pom file

2) Go the Dependency Hierarchies section in pom

3) In the upper right corner filter text box, enter the name tools.jar

4) This will show the dependency hierarchy of the tools.jar file.

5) In the right hand side Resolved Section, select the tools.jar file and right click on the jar file.

6) select the exclusion of the file.

Then rebuild the project.

Soulier answered 23/3, 2018 at 12:52 Comment(0)
H
0

For me the issue was that I installed JRE but not JDK. I know it's weird as JRE should work but it does not. With JDK same version it works good. It's a linux box and no IDE.

Hautesalpes answered 6/3, 2019 at 23:17 Comment(0)
C
0

I solved this by manually adding the tools.jar on my jdk installation's /lib to the Eclipse JRE

Window > Preferences > Installed JREs > Edit > Add external jars > select the tools.jar to add

Centaury answered 5/6, 2019 at 13:17 Comment(0)
D
0

Check in your pom.xml if tools.jar is from any other dependency. Either exclude it from there or remove dependency if not used.

Then check in your problem section if tools.jar error not appearing in eclipse.

enter image description here

Diondione answered 26/7, 2020 at 8:39 Comment(0)
H
-1

This Apple Developer article states:

tools.jar does not exist. Classes usually located here are instead included in classes.jar. Scripts that rely on the existence of tools.jar need to be rewritten accordingly.

Heng answered 12/7, 2012 at 19:1 Comment(0)
W
-2

I had to change what you had:

<systemPath>${java.home}/../lib/tools.jar</systemPath>

to the explicit path, using the JDK not the JRE like bmargulies said:

 <systemPath>C:/Program Files/Java/jdk1.6.0_24/lib/tools.jar</systemPath>

Hope that helps.

Womankind answered 14/1, 2012 at 19:49 Comment(0)
S
-2

Add this dependecy in pom.xml file.

In <systemPath> property you have to write your jdk lib path.

<dependency>  
    <groupId>com.sun</groupId> 
    <artifactId>tools</artifactId>
    <version>1.4.2</version>
    <scope>system</scope>
    <systemPath>C:/Program Files/Java/jdk1.6.0_30/lib/tools.jar</systemPath>
</dependency> 
Savick answered 12/7, 2013 at 7:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.