Java JDK 中包含的 JRE 与独立的 JRE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2541319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:04:16  来源:igfitidea点击:

JRE included with JDK vs. standalone JRE

java

提问by Dave

What's the difference between the JRE included with the JDK (located inside of the jre folder) and the standalone JRE? Is there any?

JDK 中包含的 JRE(位于 jre 文件夹内)和独立的 JRE 之间有什么区别?有没有?

采纳答案by jsight

The "standalone JRE" (sometimes also referred to as the "Public JRE") generally does not contain the server version of HotSpot. It also lacks the tools included with the JDK (JavaDB, javac, tools.jar, etc).

“独立 JRE”(有时也称为“公共 JRE”)通常不包含 HotSpot 的服务器版本。它还缺少 JDK 中包含的工具(JavaDB、javac、tools.jar 等)。

Otherwise, the runtimes are identical. Also, note that a JDK may install one (or more) JREs.

否则,运行时间是相同的。另请注意,一个 JDK 可能会安装一个(或多个)JRE。

Finally, all of the above notes are in regards to Sun's Java installers for Windows. Other vendors and platforms may (and sometimes do) vary.

最后,以上所有说明均与 Sun 的 Windows 的 Java 安装程序有关。其他供应商和平台可能(有时会)有所不同。

回答by bn.

There is no difference (unless you have a different version of the JRE). Here is the official definition from SUN/Oracle:

没有区别(除非您有不同版本的 JRE)。这是来自 SUN/Oracle 的官方定义:

http://java.sun.com/javase/6/docs/technotes/guides/index.html

http://java.sun.com/javase/6/docs/technotes/guides/index.html

JRE and JDK Sun Microsystems provides two principal software products in the JavaTM Platform, Standard Edition (JavaTM SE) family:

Java SE Runtime Environment (JRE)

The JRE provides the libraries, Java virtual machine, and other components necessary for you to run applets and applications written in the Java programming language. This runtime environment can be redistributed with applications to make them free-standing.

Java SE Development Kit (JDK)

The JDK includes the JRE plus command-line development tools such as compilers and debuggers that are necessary or useful for developing applets and applications.

JRE 和 JDK Sun Microsystems 在 JavaTM Platform, Standard Edition (JavaTM SE) 系列中提供两种主要软件产品:

Java SE 运行时环境 (JRE)

JRE 提供了运行用 Java 编程语言编写的小程序和应用程序所需的库、Java 虚拟机和其他组件。此运行时环境可以与应用程序一起重新分发,使它们独立存在。

Java SE 开发工具包 (JDK)

JDK 包括 JRE 和命令行开发工具,例如编译器和调试器,这些工具对于开发小程序和应用程序是必需的或有用的。

回答by Kevin Crowell

The "JDK" is the Java Development Kit. The JDK is bundle of software that you can use to develop Java based software. The "JRE" is the Java Runtime Environment. The JRE is an implementation of the Java Virtual Machine which actually executes Java programs.

“JDK”是Java 开发工具包。JDK 是可用于开发基于 Java 的软件的软件捆绑包。“JRE”是 Java 运行时环境。JRE 是 Java 虚拟机的一个实现,它实际执行 Java 程序。

Typically, each JDK contains one (or more) JRE's along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.

通常,每个 JDK 都包含一个(或多个)JRE 以及各种开发工具,例如 Java 源编译器、捆绑和部署工具、调试器、开发库等。

回答by JaSn

If you run a binary compare against the standalone JRE and the JRE included in the JDK they are binary different (at least in Windows version).

如果您对独立 JRE 和 JDK 中包含的 JRE 运行二进制比较,它们是二进制不同的(至少在 Windows 版本中)。

The class count in rt.jar is equal but out of curiosity, I ran 'javap' on all classes in both and compared results.

rt.jar 中的类数是相等的,但出于好奇,我对两者中的所有类都运行了“javap”并比较了结果。

The only difference I see is that the JDK verison has lines like 'Compiled from "Serializable.java' before the class code.

我看到的唯一区别是 JDK 版本在类代码之前有像 'Compiled from "Serializable.java' 这样的行。

I don't think this should have any impact on end user, so these JREs should be in fact behaving the same way.

我认为这不会对最终用户产生任何影响,因此这些 JRE 实际上应该以相同的方式运行。

回答by Daniel Nuriyev

The difference is legal. JDK is for development, JRE is for execution. You can include JRE with a product

区别是合法的。JDK 用于开发,JRE 用于执行。您可以在产品中包含 JRE