How to get tools.jar for OpenJDK 11 on Windows?

R Y picture R Y · Dec 10, 2018 · Viewed 29.6k times · Source

Background: I am trying to build Hadoop for Windows using instructions found here. I have OpenJDK 11 and have ran into the following issue while running mvn package:

Could not resolve dependencies for project org.apache.hadoop:hadoop-annotations:jar:2.5.0-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path C:\Program Files\Java\jdk-11.0.1\..\lib\tools.jar

I realised no tools.jar exists in the Windows build of OpenJDK 11. Would I have to build this from source as well? How can I get the tools.jar Maven artefact for OpenJDK 11?

Answer

Edwin Buck picture Edwin Buck · Dec 10, 2018

It was removed in JDK 9.

JEP 220 removed the well-known and frequently-referenced JARs rt.jar and tools.jar. According to its description, "The class and resource files previously stored in lib/rt.jar, lib/tools.jar, lib/dt.jar, and various other internal jar files will now be stored in a more efficient format in implementation-specific files in the lib directory.

I suggest you use a updated version of Apache Hadoop. If the updated version doesn't support Java 11 either, downgrade your Java to 1.8.

For example, the current stable Apache Hadoop is version 2.9.2, and in its instructions on how to install, it specifically references JDKs before JDK 9. For its proper support, I suggest you use OpenJDK 1.8

There is a Hadoop 3.1.1, and if you find the Java version is critical to your success, I'd look into that.