如何在 Java 11 中使用没有 JRE 的 JDK [英] How to use JDK without JRE in Java 11

查看:32
本文介绍了如何在 Java 11 中使用没有 JRE 的 JDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们计划迁移我们的 Java 8 项目以使用 Java 11.但我注意到 Java 11 没有 JRE 文件夹.

We are planning to migrate our Java 8 project to use Java 11. But I noticed that Java 11 doesn't have a JRE folder.

在 Java 9 和 Java 10 中,文件夹结构发生了变化,即 javajdk1.xjavajre1.x,其中 x是 Java 9 或 10.

In Java 9 and Java 10, folder structures are changed i.e. javajdk1.x or javajre1.x, where x is Java 9 or 10.

但在 Java 11 中,我只得到一个文件夹,即 javajdk-11.我的客户将如何在没有 jre 的情况下使用我的应用程序?

But in Java 11, I am getting only one folder, i.e. javajdk-11. How will my client use my application without jre?

我的理解是 Java 11 强制模块化我们的应用程序,需要使用 jlink 创建我们自己的 jre 以在客户端运行应用程序.

What I understood is that Java 11 is enforcing to modularize our application, and using jlink is needed to create our own jre to run the application in client.

我的理解正确吗?

推荐答案

20 年来,JDK 附带了一个 JRE,它只是安装在系统不同目录中的功能的一个子集.

For 20 years, the JDK shipped with a JRE which was just a subset of its functionality installed in a different directory on your system.

事实上,它附带了两个相同的 JRE,一个安装在 JDK 安装目录中,一个安装在外部.

In fact, it shipped with TWO identical JREs, one installed inside the JDK installation directory and one outside it.

这一直让我感到困惑,因为维护人员这样做完全是浪费精力,而且完全浪费了安装它的计算机上的磁盘空间,因为 JRE 只是复制了一些东西JDK 已经可以做到了.

This has always puzzled me as it's a complete waste of effort on the part of the maintainers to make this so, and a complete waste of disk space on the computer you install it on, as that JRE just duplicates some of the things the JDK can do already.

最后,在 Java 11 中,Oracle 和 OpenJDK 团队决定结束这种愚蠢的做法,只发布一个东西,即 JDK.安装时,这个 JDK 在您的硬盘上实际上比以前单独的旧 JRE 小,甚至删除了一些有效的论点,即您希望为磁盘空间有限的设备使用单独的 JRE,这个论点从未解释为什么 2 个 JRE 会最初使用单个 JDK 安装,但这样做是为了证明需要 JRE 作为 JDK 的精简运行时环境.

Finally, with Java 11, Oracle and the OpenJDK team decided to end this silliness and just distribute a single thing, the JDK. This JDK when installed is actually smaller on your hard disk than the old JRE alone used to be, removing even the somewhat valid argument that you'd want a separate JRE for devices with limited disk space, an argument that never explained why 2 JREs would be installed with a single JDK in the first place but was made to justify the need for a JRE as a stripped down runtime environment for the JDK.

因此,不需要单独的JRE,而且已经很长时间没有了,更不用说将其包含并强制安装为JDK安装的一部分了.

Ergo, there is no need for a separate JRE, and there hasn't been one for a long time, let alone for including and forcibly installing it as part of the JDK installation.

不,您不需要创建自己的 JRE.只需在客户端计算机上安装 OpenJDK 并确保将 $JAVA_HOME/bin 添加到系统路径中,就像您必须对旧的 JRE 做的一样.

And no, you don't need to create your own JRE. Just install the OpenJDK on the client machines and make sure you add the $JAVA_HOME/bin to the system path, just as you had to do with old JREs.

哦,去掉某些版本的旧 JRE 安装程序不会放置在那里的任何 java*.exe 文件的 Windows 目录树,以及一些 JRE 安装程序添加的一些奇怪条目的系统路径.

And oh, strip the Windows directory tree of any java*.exe files which some versions of the old JRE installer were wont to place there, as well as the system path which also had some weird entries added by some JRE installers.

这篇关于如何在 Java 11 中使用没有 JRE 的 JDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆