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?
For Mac users
[1] To find out where your VM is type this /usr/libexec/java_home
[2] vi ./Eclipse.app/Contents/MacOS/eclipse.ini
[3]
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/
-vmargs ........ ........
[4] In Eclipse , Update Maven
[5] Sing All is Well :-)
This dependency should work as expected. If in doubt, try the command line version of Maven because the Eclipse plugin is very brittle when it comes to dependency resolution.
Unlike other parts of Eclipse, it is unable to create even a partial classpath for the build if something is wrong with the POM, so the error could be something else.
If all else fails, try to install the file into your local repository, so you can see the next error.
This issue due to wrong java configuration. every IDE required full JDK pack. becuase tools.jar available inside JDK lib not jre lib
go to control panel change environment path variable to C:\Program Files\Java\jdk1.8.0_31\jre\bin.
change JAVA_HOME to C:\Program Files\Java\jdk1.8.0_31.
open IDE(eclipse or STS) change JRE system library to C:\Program Files\Java\jdk1.8.0_31
then restart IDE. it will work
A hacky solution that worked for me:
If m2e is complaining that the following jar is not found in the Maven cache (you can find the bad path in the error log for the pom file, or in the "Java Build Path > Maven Dependencies" list):
then try the following command (fill in
JAVA_VERSION_HERE
for an installed JDK, e.g. jdk1.8.0_191-amd64, then use the two path sections after.m2/repository/
above to determine the correctgroupId
, and replace1.6
with whatever version m2e is complaining about -- it may or may not matter if the JDK you have installed matches the version m2e is complaining about):This command copies
tools.jar
from your JDK and puts it into the Maven cache, also creating apom.xml
file for it so that it can be used by Maven.I read this and tried various things. What worked for me was this: I changed the windows --> preferences --> java --> installed JREs to point to the JDK instead. That solved this problem.