无法找到用于Java SE 14的tools.jar文件。

huangapple go评论65阅读模式
英文:

Unable to locate tools.jar for Java SE 14

问题

tools.jar 在最新的 Java 版本 14 中不存在。有人能帮助我理解它是否被替换,或者它被放在了哪里吗?

我的系统信息是:

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

我通过从 Oracle 的网站 下载 jdk-14.0.2_windows-x64_bin.exe 来安装了最新版本的 Java。

安装完成后,我在安装文件夹 C:\Program Files\Java\jdk-14.0.2\lib 中查找,但没有找到 tools.jar

我们是否需要安装其他与 JRE 相关的软件包以获取 tools.jar

如果没有 tools.jar,那么有什么替代品呢?

英文:

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?

答案1

得分: 4

> 我们需要为JRE安装任何其他软件包吗,以帮助处理tools.jar吗?

不需要。没有简单的解决方法。

> 如果没有tools.jar,有什么替代品?

没有直接的替代品。相反,您必须更改应用程序,使其不依赖于该文件的存在。

Java 9+使用Java平台模块系统,而不是tools.jar、rt.jar等。请参见本页上的另一个答案,作者是Giorgi Tsiklauri。

  • 如果依赖关系在您自己的代码中,更改代码,以便通过Tools API访问Java编译器等。如果您的代码正在检查是否存在tools.jar,删除该检查,并且(如果必要)以其他方式进行检查。

  • 如果依赖关系在第三方代码(可能是工具)中,您需要将其升级到与您尝试使用的Java版本兼容的版本。

英文:

> 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.

答案2

得分: 3

自Java 9开始已移除

Java 9起,JEP 220:模块化运行时映像移除了rt.jartools.jardt.jar和其他一些jar文件。

引用JEP中的描述:

>已移除:rt.jar和tools.jar
>
> 之前存储在lib/rt.jar、lib/tools.jar、lib/dt.jar以及其他各种内部JAR文件中的类和资源文件现在以一种更高效的格式存储在lib目录中的实现特定文件中。这些文件的格式未经指定,可能会在不事先通知的情况下进行更改。

英文:

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.

答案3

得分: 1

以下是翻译好的内容:

我刚刚几分钟前也遇到了同样的问题。

我通过在Ubuntu终端中输入以下命令来下载openjdk-11-jdk-headless

$ sudo apt install openjdk-11-jdk-headless

然后,在IntelliJ IDEA中打开项目结构。快捷键:(Ctrl+Alt+Shift+S)。

你可以查看我的截图以获取可视化指南。

在那里选择jdk版本(这里是openjdk 11),并将语言 项目语言级别 更改为 11

无法找到用于Java SE 14的tools.jar文件。

英文:

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

无法找到用于Java SE 14的tools.jar文件。

huangapple
  • 本文由 发表于 2020年9月2日 06:40:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/63696357.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定