Missing tools.jar in local repository breaks m2eclipse

47,388

Solution 1

I was facing the same problem and needed to do the following things

  • Added -vm path/to/jdk/bin in eclipse.ini file
  • Clean the existing workspace and reload the project.

It worked for me seamlessly.

Its worth to add that, in my eclipse.ini file I had to add the -vm ... lines at the top of the file. like

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

Make sure that, -vm option is placed before -vmargs as everything after -vmargs is passed directely to vm and selecting a particular is depend on -vm option.

Solution 2

I had this issue, but I have fixed by using the steps below:

Case1:

Eclipse by default pointing to JRE but eclipse maven plugin required JDK so point to JDK

Window -> Preperences -> Java -> Installed JREs

change it to JDK

Follow the steps to change to JDK from JRE

  1. In the Eclipse IDE go to: Window… Preferences… Installed JREs
  2. Select defaulted JRE and click on Edit.
  3. Click on Add External Jar
  4. I found tools.jar in “C:\Program Files\Java\jdk1.6.0_22\lib” and added.

Now I can build my project without any issue. Is this the correct way to solve this issue?

Solution 3

I had the same problem - Eclipse couldn't find a tools.jar. As I found out the reason is that Eclipse used a JRE and not a JDK. You have to add a -vm parameter to eclipse.ini that is pointed to your JDK bin directory:
...
-vm
path_to_jdk\bin
...

This should fix the problem.

Solution 4

excludes tools jar from the struts dependency.

<exclusions>
    <exclusion>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
    </exclusion>
</exclusions>

Solution 5

Download http://repository.ops4j.org/maven2/tools/tools/1.5.0/ and put the jar in the C:\Documents and Settings\Administrador\.m2\repository\com\sun\tools\1.5.0. Good luck.

Share:
47,388
wds
Author by

wds

Java coder with some experience with a bunch of scripting languages and some C, mostly on linux.

Updated on July 09, 2022

Comments

  • wds
    wds almost 2 years

    The problem I'm experiencing is that eclipse can't resolve any of the dependencies of my project. This causes problems because even though the dependencies seem to work alright when coding (I get autocompletion) I still get a huge list of errors referring to missing artifacts.

    When filtering these, I found the following:

    The container 'Maven Dependencies' references non existing library '/home/[...]/.m2/repository/com/sun/tools/1.5.0/tools-1.5.0.jar'

    It seems that this dependency was introduced by struts2, who have a profile set up as follows in their pom:

    <dependency>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
        <version>1.5.0</version>
        <scope>system</scope>
        <systemPath>${java.home}/../lib/tools.jar</systemPath>
    </dependency>
    

    That systemPath resolves and so I don't see a reason why this would be causing trouble. In any case, is there a way to tell eclipse that this m2eclipse dependency is a system dependency that is not found in the local repository?