Missing tools-1.6.jar with Eclipse and Maven
Asked Answered
A

12

14

I am trying to get a project to run using Maven in Eclipse, but I am getting this error below. The tools.jar is in the JDK's lib folder, but tools-1.6.jar doesn't seem to exist on my computer. I am using the JDK 1.7 and my JAVA_HOME is pointing to that folder (as is my eclipse.ini) Anyone know where I can get this file or what I might be doing wrong?

The container 'Maven Dependencies' references non existing library C:\Users\sejohnson\.m2\repository\com\sun\tools\1.6\tools-1.6.jar

Astera answered 27/8, 2011 at 20:52 Comment(1)
your .pom? your .project and .classpath files?Pelerine
G
16

The tools-x.y.z.jar should be provided by your JDK.

Make sure that eclipse is run by JDK and not by JRE by adding -vm option in eclipse.ini.

For example:

-vm
C:\Program Files\Java\jdk1.6.0_26\bin\javaw

New line after -vm is crucial.

it should be right above

-vmargs

See also Eclipse Maven Plugin Configuration Problem

Gefell answered 19/10, 2011 at 4:26 Comment(0)
C
14

I had exactly the same problem and end up adding the following dependency to the pom file:

    <dependency>
        <groupId>jdk.tools</groupId>
        <artifactId>jdk.tools</artifactId>
        <version>${java.version}</version>
        <scope>system</scope>
        <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
    </dependency>

This fixed the problem and made tools.jar available for QueryDSL plugin in my project. Hope this helps. Note, make sure that JDK version is used instead of JRE.

Edit: Recently noted that problem reappeared when I moved on new dev platform, in my case it was Ubuntu 12.10. The fix was to add ${JAVA_HOME}/bin to the $PATH

Crenate answered 25/3, 2013 at 15:27 Comment(0)
P
5

It could be that your eclipse is defaulting to your 32bit version of your jre. If you do everything right with JAVA_HOME set to C:\Program Files\Java\jdk1.6.0_21\bin and your running a 32bit version of eclipse you'll end up using something like C:\Program Files (x86)\Java\jre6\bin.

once you fix your jdk issue You will need to pass it on the end of a shortcut -vm "C:\Program Files (x86)\Java\jdk1.6.0_31\bin"

Or fix your JAVA_HOME

Other suggestions have been to make sure your eclipse is using the jdk not jre http://gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx

You'll find other post if you search tools.jar or playn another project with this common maven dependency issue.

Poteen answered 18/4, 2012 at 4:59 Comment(1)
I just encountered this issue, and pointing Eclipse to the JDK instead of the JRE fixed it for me. Thanks!Druid
G
1

Can you check your pom.xml for dependencies around tools? A good source is mvnrepository.com, finally does your project compile outside of eclipse? Does mvn clean compile work in a dos box or shell? If it does maybe you just need to regenerate the eclipse project files with mvn eclipse:eclipse then refresh your project in eclipse

Glengarry answered 27/8, 2011 at 20:58 Comment(0)
C
1

The tools.jar is not provided in any public repository (as I know). If your pom.xml references a file in your local repository you must install it by your own. The pom.xml you are using apparently expects that someone created/installed a tools-1.6.jar in an accecable Maven repository (e.g. to a company central maven repositiory manager like Nexus).

If that does not fit for you try to change the dependency like explained in the Maven FAQs.

Christine answered 29/8, 2011 at 14:34 Comment(0)
B
1

In addition to all the stated above, which could mean different steps to diagnose the problem and ultimately providing a proper solution, I'd first check in a command line (meaning, outside Eclipse runtime). Doing a plain 'mvn clean install' from a command line would give you the following:

  1. Certainty of whether you have the java executables correctly set (as they're the defaults used by all java apps, including of course eclipse,
  2. Certainty that your maven version does resolve the tools*.jar requirement via JDK provisioning adequately

Using these two facts you can rule out problems at Java installation and Maven installation levels. Then you can move on to making Eclipse use the same settings as you can use (JAVA JDK HOME, MAVEN HOME) in a command line, as the other answers above explain with good detail (specifically brimstedt's and josh's).

Blakeblakelee answered 21/1, 2013 at 16:37 Comment(0)
A
1

I had this same problem and it turned out that one of the dependencies in my POM file was transitively adding the dependency to the jdk.tools jar which I didn't need (and was causing the problems with the Eclipse Maven plugin). My solution was to exclude it from the problematic dependency like this:

<dependency>
  <groupId>it.unimi.di</groupId>
  <artifactId>mg4j-big</artifactId>
  <version>${mg4j-big.version}</version>
  <exclusions>
    <exclusion>
      <groupId>jdk.tools</groupId>
      <artifactId>jdk.tools</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Try looking for the dependency that is transitively importing the jdk.tools jar and just exclude like I did above. This should solve your problem.

Atbara answered 10/6, 2015 at 23:49 Comment(1)
Thanks... I think that is the proper solution! Everything else are just workarounds or hacks.Politician
P
0

Having the same problem, I had to manually add the tools.jar in eclipse: Preferences -> Java -> Installed JREs -> Select jre -> Edit -> Add External JARs -> Find and select tools.jar -> Finish. Now it works.

Phalanger answered 19/2, 2015 at 12:36 Comment(0)
M
0

Here is another option if you are having this build problem. I had the same build problem and i tried all of the above suggestions and the problem was still there. Then i noticed that my system path had the following "C:\ProgramData\Oracle\Java\javapath" as the first item.

I am not sure which program installed it. And when i checked the folder it only had some links ( short cuts). I removed this from the system path and the build error was resolved. Hope this helps someone else in the same situation.

Maziar answered 15/5, 2016 at 17:46 Comment(0)
T
0

Echo @Gopal Ramakrishnan. I had same problem in the env path (windows OS). It has "C:\ProgramData\Oracle\Java\javapath" in which has java.exe, thus impacted the actual jdk path when starting eclipse. Simply remove that resolved the problem. I am pretty sure the "C:\ProgramData\Oracle\Java\javapath" was quietly added by oracle "sql developer"...

Thorwald answered 11/7, 2017 at 2:51 Comment(0)
D
0

In my case it turned out that I had this dependency in the pom.xml

<dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.6.0</version>
            <scope>system</scope>
            <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>

However JAVA_HOME was set on startup of Eclipse to a JRE instead of a JDK.

So the tools.jar in fact did not exist for this reason

Delldella answered 6/2, 2018 at 1:26 Comment(0)
P
0

Manually remove artifact from maven :

  1. Goto "Dependency Hierarchy" Tab of pom.xml
  2. Filter jdk.tools eg: (jdk.tools:1.6 [system])
  3. Right click on jdk.tools and click "Exclude Maven Artifact"

Error will be resolved.

Physique answered 28/2, 2022 at 10:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.