JVM, JDK, JRE和OpenJDK之间的区别是什么?

我在用Java编程时遇到了这些短语,它们之间有什么区别?


当前回答

JVM

JVM (Java虚拟机)是一种抽象机器。它是一个提供运行时环境的规范,在该环境中可以执行java字节码。 jvm可用于许多硬件和软件平台。

JRE

JRE是Java运行时环境的首字母缩写。它用于提供运行时环境。它是JVM的实现。它是物理存在的。它包含一组库+ JVM在运行时使用的其他文件。

JDK

JDK是Java Development Kit的首字母缩写。它是物理存在的。它包含JRE +开发工具。

链接:- http://www.javatpoint.com/difference-between-jdk-jre-and-jvm

其他回答

JDK:你需要编写和运行java代码的完整包

OpenJDK:一个独立的JDK实现,使它变得更好

JVM:将Java代码转换为字节码,并提供说明如何编译、加载、验证、检查错误和执行Java代码的规范。

JRE: JVM的实现,一些Java库被用来运行程序

JVM Java虚拟机,实际执行Java字节码。 它是JAVA平台上的执行块。它将字节码转换为机器代码。

JRE Java运行时环境,提供了执行Java应用程序的最低要求;它由Java虚拟机(JVM)、核心类和支持文件组成。

JDK Java开发工具包,它拥有开发应用程序软件的所有工具。它是JRE+JVM

Open JDK是Java平台的免费开源实现。

JVM

The Java Virtual Machine (JVM) is the virtual machine that runs the Java bytecodes. The JVM doesn't understand Java source code; that's why you need compile your *.java files to obtain *.class files that contain the bytecodes understood by the JVM. It's also the entity that allows Java to be a "portable language" (write once, run anywhere). Indeed, there are specific implementations of the JVM for different systems (Windows, Linux, macOS, see the Wikipedia list), the aim is that with the same bytecodes they all give the same results.

JDK和JRE

要解释JDK和JRE之间的区别,最好是阅读Oracle文档并参考图:

Java Runtime Environment (JRE) The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language. In addition, two key deployment technologies are part of the JRE: Java Plug-in, which enables applets to run in popular browsers; and Java Web Start, which deploys standalone applications over a network. It is also the foundation for the technologies in the Java 2 Platform, Enterprise Edition (J2EE) for enterprise software development and deployment. The JRE does not contain tools and utilities such as compilers or debuggers for developing applets and applications. Java Development Kit (JDK) The JDK is a superset of the JRE, and contains everything that is in the JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.

注意,Oracle并不是唯一提供jdk的公司。

OpenJDK

OpenJDK是JDK的开源实现,也是Oracle JDK的基础。Oracle JDK和OpenJDK之间几乎没有区别。

区别在这个博客中说明:

Q: What is the difference between the source code found in the OpenJDK repository, and the code you use to build the Oracle JDK? A: It is very close - our build process for Oracle JDK releases builds on OpenJDK 7 by adding just a couple of pieces, like the deployment code, which includes Oracle's implementation of the Java Plugin and Java WebStart, as well as some closed source third party components like a graphics rasterizer, some open source third party components, like Rhino, and a few bits and pieces here and there, like additional documentation or third party fonts. Moving forward, our intent is to open source all pieces of the Oracle JDK except those that we consider commercial features such as JRockit Mission Control (not yet available in Oracle JDK), and replace encumbered third party components with open source alternatives to achieve closer parity between the code bases.

JDK 11的更新

Donald Smith的一篇文章试图消除Oracle JDK和Oracle的OpenJDK之间的差异:https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later

正如@Alan Evangelista在评论中提到的,Java Web Start已被Oracle在Java SE 9中弃用,并在Java SE 11中删除。

开发人员使用JDK进行开发,首先我们编写.java源代码 开发人员调试代码并将代码编译成JRE中的.class字节码可执行文件 可执行文件由JVM执行,将字节码转换为机器可以执行的本机机器码

他们的关系如下:

参考: Java JDK、JRE和JVM

JVM: java的虚拟机。告诉机器用Java代码做什么。不能按原样下载JVM。它被打包在其他组件中。

JRE:上面提到的其他组件是JRE。 它是JVM+其他jar创建运行时环境

JDK:包含JRE(JRE又包含JVM)。获得JDK后,不需要分别安装JRE和JVM。它包含编译器,编译你的.java文件到.class文件