JVM, JDK, JRE & 有什么区别?开放式JDK? [英] What is the difference between JVM, JDK, JRE & OpenJDK?

查看:31
本文介绍了JVM, JDK, JRE & 有什么区别?开放式JDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JVMJDKJRE 和有什么区别?OpenJDK?

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

解决方案

JVM

Java 虚拟机 (JVM) 是运行 Java 字节码的虚拟机.JVM 不理解 Java 源代码;这就是为什么您需要编译 *.java 文件以获取包含 JVM 理解的字节码的 *.class 文件的原因.它也是允许 Java 成为可移植语言"的实体.(一次编写,随处运行).实际上,对于不同的系统(Windows、Linux、macOS、请参阅维基百科列表),目的是使用相同的字节码,它们都给出相同的结果.

JDK 和 JRE

要解释JDK和JRE的区别,最好阅读Oracle 文档 并查阅图表:

<块引用>

Java 运行时环境 (JRE)

Java 运行时环境 (JRE) 提供库、Java 虚拟机和其他组件来运行用 Java 编程语言编写的小程序和应用程序.此外,JRE 还包含两项关键部署技术: Java Plug-in,它使小应用程序能够在流行的浏览器中运行;和 Java Web Start,它通过网络部署独立的应用程序.它也是 Java 2 Platform, Enterprise Edition (J2EE) 中用于企业软件开发和部署的技术的基础.JRE 不包含用于开发小程序和应用程序的工具和实用程序,例如编译器或调试器.

Java 开发工具包 (JDK)

JDK 是 JRE 的超集,包含 JRE 中的所有内容,以及开发小程序和应用程序所需的编译器和调试器等工具.

请注意,Oracle 并不是唯一提供 JDK 的公司.

OpenJDK

OpenJDK 是 JDK 的开源实现,并且Oracle JDK 的基础.Oracle JDK 和 OpenJDK 几乎没有区别.

差异在此中说明博客:

<块引用>

问:在 OpenJDK 存储库中找到的源代码与您用于构建 Oracle JDK 的代码有什么区别?

A:非常接近 - 我们的 Oracle JDK 版本构建过程是在 OpenJDK 7 上构建的,只添加了几部分,例如部署代码,其中包括 Oracle 对 Java 插件和 Java WebStart 的实现,以及一些封闭源代码的第三方组件,如图形光栅化器,一些开源的第三方组件,如 Rhino,以及一些零碎的东西,如附加文档或第三方字体.展望未来,我们的目的是开源 Oracle JDK 的所有部分,除了我们考虑的商业功能,如 JRockit Mission Control(Oracle JDK 中尚未提供),并用开源替代品替换受阻的第三方组件以实现更接近的平等代码库之间.

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 在 Java SE 9 中已被 Oracle 弃用,并在 Java SE 11 中删除.

What is the difference between JVM, JDK, JRE & OpenJDK?

I was programming in Java and I encountered these phrases, what are the differences among them?

解决方案

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 and JRE

To explain the difference between JDK and JRE, the best is to read the Oracle documentation and consult the diagram:

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.

Note that Oracle is not the only one to provide JDKs.

OpenJDK

OpenJDK is an open-source implementation of the JDK and the base for the Oracle JDK. There is almost no difference between the Oracle JDK and the OpenJDK.

The differences are stated in this blog:

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.

Update for JDK 11

An article from Donald Smith try to disambiguate the difference between Oracle JDK and Oracle's OpenJDK : https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later

As mentionned in comments by @Alan Evangelista, Java Web Start has been deprecated by Oracle in Java SE 9 and removed in Java SE 11.

这篇关于JVM, JDK, JRE &amp; 有什么区别?开放式JDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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