Reputation: 632
I was trying to download and install new jdk for brushing up my java, but it seems the jdk installation doesn't have the tools.jar
file in the lib directory. Am I missing something?
I tried installing it from this link https://www.oracle.com/java/technologies/downloads/#jdk17-windows
I tried both exe and msi but none seems to work and when I tried running the code I get Error:Cannot determine path to 'tools.jar' library for 17 (C:\Program Files\Java\jdk-17)
I tried to search for this issue, but most question where asked by people who installed jre
instead, or who didn't set the set "JAVA_HOME=C:\Program Files\Java\jdk-17"
>java --version
java 17 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Upvotes: 12
Views: 21677
Reputation: 21
just download tools.jar file from link: http://www.java2s.com/Code/Jar/t/Downloadtools180jar.htm then add tools.jar file into jdk file lib folder.It will solve error
Upvotes: 2
Reputation: 102902
tools.jar
contains, primarily, javac
(the compiler).
The transition from JDK8 to JDK9 broke a ton of java stuff. Including removing this jar. It's now in a module. Whatever software is looking for tools.jar will not be compatible with this new model. Oracle hides behind the idea that none of this was specced, and in fairness to Oracle/OpenJDK, it wasn't. In other words, relying on 'tools.jar' never was actually supported, but then again, the things that 'rely' on this wanted to compile java code. There is no alternative short of shipping the compiler with your app, which has license issues.
At any rate, the solution is therefore simple: Either upgrade whatever software is throwing this error at you, or if you already did / you cant, downgrade to JDK8.
Note that you can install multiple JDKs on a single system, and you can e.g. run intellij on JDK8 and then write java code inside it targeted at jDK17, no problem.
Upvotes: 11