4

tools.jar is not present in latest Java version 14. Can anyone help me to understand whether it is replaced or where it is?

My system is having:

C:\Users\Admin>wmic os get osarchitecture
OSArchitecture
64-bit

I have installed latest Java version by downloading jdk-14.0.2_windows-x64_bin.exe from Oracle's website.

After Installation, I looked in installation folder C:\Program Files\Java\jdk-14.0.2\lib and it is not having tools.jar.

Do we need to install any other packages for JRE that would help with tools.jar?

If tools.jar is not present, what is the replacement?

Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66
Madala
  • 41
  • 1
  • 4
  • Possibly related: [How to get tools.jar for OpenJDK 11 on Windows?](https://stackoverflow.com/q/53707666). In short update other tools to versions which no longer rely on `tools.jar`. – Pshemo Sep 01 '20 at 22:50
  • https://stackoverflow.com/questions/26973145/maven-build-error-tools-jar-not-found-in-jre/26973294 – Laura Liparulo Sep 01 '20 at 23:03
  • @LauraLiparulo your link refers to the Jdk 1.7. – Giorgi Tsiklauri Sep 01 '20 at 23:14
  • @Pshemo some part of why is explained but does not completely answer Though this from "JEP 220 removed the well-known and frequently-referenced JARs rt.jar and tools.jar. According to it's 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." – Madala Sep 01 '20 at 23:19
  • @LauraLiparulo your link refers to the Jdk 1.7. correct.. – Madala Sep 01 '20 at 23:20
  • That is why I only said it could be "Possibly *related*" and didn't mark your question as duplicate. Anyway we still don't know why you need `tools.jar`. If it is some other tool which depends on it try updating that tool. – Pshemo Sep 01 '20 at 23:20
  • I have installed JDK 14 on my WIN 10 successfully and I have tools-1-9-1.jar. I think it was just provided by the installation – Laura Liparulo Sep 03 '20 at 09:32

3 Answers3

4

Do we need to install any other packages for JRE that would help with tools.jar?

No. There is no simple workaround.

If tools.jar is not present, what is the replacement?

There isn't a direct replacement. Instead you must change the application so that it doesn't depend on the existence of the file.

Java 9+ uses the Java Platform Module System rather than tools.jar, rt.jar and so one. See the other Answer on this page, by Giorgi Tsiklauri.

  • If the dependency is in your own code, change the code so that it access the Java compilers, etc via the Tools API. If your code is checking for the existence of tools.jar, remove the check and (if necessary) check a different way.

  • If the dependency is in third-party code (probably a tool) you need to upgrade it to a version that is compatible with the version of Java that you are trying to use.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
3

Removed as of Java 9

Effective since Java 9, JEP 220: Modular Run-Time Images removed rt.jar, tools.jar, dt.jar and some other jar files.

To quote from the JEP:

Removed: rt.jar and tools.jar

The class and resource files previously stored in lib/rt.jar, lib/tools.jar, lib/dt.jar, and various other internal JAR files are now stored in a more efficient format in implementation-specific files in the lib directory. The format of these files is not specified and is subject to change without notice.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66
  • so the functionality of tools.jar has been replaced with ? – Madala Sep 02 '20 at 00:18
  • 1
    "*JAR files are now stored in a more efficient format in implementation-specific files in the lib directory.*" - quote from the answer. Different functionality went into different (corresponding) files. – Giorgi Tsiklauri Sep 02 '20 at 00:19
  • 1
    @Madala JDK-specific modules. For example, `javac` is in the `jdk.compiler` module, `javadoc` is in the `jdk.javadoc` module, and so on (though note for `javac` and `javadoc` you may want to rely on the standard `java.compiler` module unless you need access to low-level, vendor-specific, not-necessarily-stable APIs). – Slaw Sep 02 '20 at 02:07
1

I had the same problem just few minutes back.

I downloaded openjdk-11-jdk-headless by typing the following command from Ubuntu terminal:

$ sudo apt install openjdk-11-jdk-headless

Then, open the project structure inside intellij idea. shortcut: (Ctrl+Alt+Shift+S).

You can see my screenshot for a visual guide.

There select the jdk version (openjdk 11 here) and change the language Project Language Level to 11

enter image description here

Tuhin Mitra
  • 555
  • 7
  • 19