简体   繁体   English

tools.jar 不自带jdk安装

[英]tools.jar does not come with jdk installation

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.我试图下载并安装新的 jdk 以刷新我的 java,但似乎 jdk 安装在 lib 目录中没有tools.jar文件。 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)我尝试从这个链接安装它https://www.oracle.com/java/technologies/downloads/#jdk17-windows我尝试了 exe 和 msi 但似乎都没有,当我尝试运行代码时我得到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"我试图搜索这个问题,但大多数问题是由安装jre的人或没有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)

tools.jar contains, primarily, javac (the compiler). tools.jar主要包含javac (编译器)。

The transition from JDK8 to JDK9 broke a ton of java stuff.从 JDK8 到 JDK9 的过渡打破了很多 java 的东西。 Including removing this jar.包括移除这个 jar。 It's now in a module.它现在在一个模块中。 Whatever software is looking for tools.jar will not be compatible with this new model.无论是什么软件都在寻找工具。jar 将与这款新的 model 不兼容。 Oracle hides behind the idea that none of this was specced, and in fairness to Oracle/OpenJDK, it wasn't. Oracle 隐藏了这样的想法,即这些都不是指定的,并且公平地对待 Oracle/OpenJDK,它不是。 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.换句话说,实际上从未真正支持依赖“tools.jar”,但话又说回来,“依赖”它的东西想要编译 java 代码。 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.无论如何,解决方案因此很简单:要么升级任何向你抛出此错误的软件,要么如果你已经这样做/你不能,降级到 JDK8。

Note that you can install multiple JDKs on a single system, and you can eg run intellij on JDK8 and then write java code inside it targeted at jDK17, no problem.请注意,您可以在单个系统上安装多个 JDK,例如,您可以在 JDK8 上运行 intellij,然后在其中针对 jDK17 编写 java 代码,没问题。

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只需从链接下载 tools.jar 文件: http://www.java2s.com/Code/Jar/t/Downloadtools180jar.htm然后添加工具。Z68995FCBF432492D15484DkdkA 文件夹将解决Z 文件错误9D15484DkdkA 文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM