Build error: missing artifact com.sun:tools:jar:1.6

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

See 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.


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.


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>

Tags:

Java

Maven

Playn