Missing artifact jdk.tools:jdk.tools:jar:1.8

Introduction

When eclipse is set up with maven at times it will complain with this error Missing artifact jdk.tools:jdk.tools:jar:1.8

Here is the video to troubleshoot and fix the issue.

Root Cause

tools.jar will be under $JAVA_HOME/lib, but eclipse expects to be under $JAVA_HOME/../lib (which means there should be directory one level up than $JAVA_HOME by name lib and it should have the jar file

Troubleshooting

Right click on the project -> “Run As” -> “Maven Install”

It will show output like this and you have to focus on this line
[ERROR] Failed to execute goal on project mr: Could not resolve dependencies for project org.itversity:mr:jar:0.0.1-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.8 at specified path C:\\Program Files\Java\jre1.8.0_101/../lib/tools.jar -> [Help 1]

[INFO] Scanning for projects...
[INFO][INFO] ------------------------------------------------------------------------
[INFO] Building demomr 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom (7 KB at 6.5 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.500 s
[INFO] Finished at: 2016-09-13T22:55:05-05:00
[INFO] Final Memory: 11M/176M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project mr: Could not resolve dependencies for project org.itversity:mr:jar:0.0.1-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.8 at specified path C:Program FilesJavajre1.8.0_101/../lib/tools.jar -> [Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR][Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[INFO] Scanning for projects...
[INFO][INFO] ------------------------------------------------------------------------
[INFO] Building demomr 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom (7 KB at 6.5 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.500 s
[INFO] Finished at: 2016-09-13T22:55:05-05:00
[INFO] Final Memory: 11M/176M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project mr: Could not resolve dependencies for project org.itversity:mr:jar:0.0.1-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.8 at specified path C:\\Program Files\Java\jre1.8.0_101/../lib/tools.jar -> [Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR][Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Path: C:\\Program Files\Java\jre1.8.0_101/../lib/tools.jar

It is expecting tools.jar to be in C:\\Program Files\Java\lib\tools.jar, but by default tools.jar will be under C:\\Program Files\Java\jre<version>\lib\tools.jar (some times it could be jdk)

Solution

You have to copy tools.jar to the location eclipse is expecting. Once the tools.jar is copied, either restart eclipse or make some modification to pom.xml and save it. It will rebuild the workspace automatically and issue will be fixed.

 

Add Comment

Leave a Reply

shares

Big Data Introduction - YouTube live video

Please click here

Subscribe!