Differences Between Oracle JDK and OpenJDK – Oracle JDK和OpenJDK之间的差异

最后修改: 2019年 2月 6日

中文/混合/英文(键盘快捷键:t)

1. Introduction

1.介绍

In this tutorial, we’ll explore the differences between Oracle Java Development Kit and OpenJDK. First, we’ll take a closer look at each of them, and then we’ll compare them. Finally, we’ll list other JDK implementations.

在本教程中,我们将探讨Oracle Java Development KitOpenJDK之间的区别。首先,我们将仔细看看它们各自的情况,然后再进行比较。最后,我们将列出其他JDK的实现。

2. Oracle JDK and Java SE History

2.Oracle JDK和Java SE的历史

JDK (Java Development Kit) is a software development environment used in Java platform programming. It contains a complete Java Runtime Environment, a so-called private runtime. It’s thus named because it contains more tools than the standalone JRE, as well as the other components needed for developing Java applications.

JDK(Java Development Kit)是一个用于Java平台编程的软件开发环境。它包含一个完整的Java运行时环境,即所谓的私有运行时。它之所以这样命名是因为它包含了比独立的JRE更多的工具,以及开发Java应用程序所需的其他组件。

Oracle strongly recommends using the term JDK to refer to the Java SE (Standard Edition) Development Kit (there are also Enterprise Edition and Micro Edition platforms).

Oracle强烈建议使用JDK一词来指代Java SE(标准版)开发工具包(还有企业版和微型版平台)。

Let’s take a look at the Java SE history:

让我们来看看Java SE的历史。

  • JDK Beta – 1995
  • JDK 1.0 – January 1996
  • JDK 1.1 – February 1997
  • J2SE 1.2 – December 1998
  • J2SE 1.3 – May 2000
  • J2SE 1.4 – February 2002
  • J2SE 5.0 – September 2004
  • Java SE 6 – December 2006
  • Java SE 7 – July 2011
  • Java SE 8 (LTS) – March 2014
  • Java SE 9 – September 2017
  • Java SE 10 (18.3) – March 2018
  • Java SE 11 (18.9 LTS) – September 2018
  • Java SE 12 (19.3) – March 2019

Note: the versions in italics are no longer supported.

注意:斜体字的版本已不再被支持。

We can see that the major releases of Java SE came approximately every two years until Java SE 7. It took five years to move from Java SE 6, and another three after that to reach Java SE 8.

我们可以看到,Java SE的主要版本大约每两年一次,直到Java SE 7。从Java SE 6开始,花了五年时间,之后又花了三年时间才达到Java SE 8。

Since Java SE 10, we’ve come to expect new releases every six months. However, not all releases will be the Long-Term-Support (LTS) releases. As a result of Oracle’s release plan, the LTS product releases will only happen every three years.

自从Java SE 10以来,我们已经开始期待每六个月一次的新版本。然而,并非所有的版本都是长期支持(LTS)版本。由于甲骨文的发布计划,LTS产品的发布将只发生在每三年一次。

Java SE 11 is the latest LTS version, and Java SE 8 will receive free public updates until December 2020 for non-commercial usage.

Java SE 11是最新的LTS版本,而Java SE 8将获得免费的公共更新,直到2020年12月的非商业使用。

This development kit got its current name after Oracle bought Sun Microsystems in 2010. Before that, the name was SUN JDK, and it was the official implementation of the Java programming language.

这个开发工具包在2010年甲骨文公司收购了Sun Microsystems之后得到了它现在的名字。在此之前,它的名字是SUN JDK,它是Java编程语言的官方实现。

3. OpenJDK

3.淘宝网

OpenJDK is a free and open-source implementation of the Java SE Platform Edition. It was initially released in 2007 as the result of the development that Sun Microsystems started in 2006.

OpenJDK是Java SE平台版的免费和开源的实现。它最初是在2007年发布的,是Sun Microsystems在2006年开始的开发成果。

We should emphasize that OpenJDK is an official reference implementation of a Java Standard Edition since version SE 7.

我们应该强调,OpenJDK是自SE 7版本以来Java标准版的官方参考实现

Initially, it was based only on the JDK 7, but since Java 10, the open-source reference implementation of the Java SE platform is the responsibility of the JDK Project. And, just like for Oracle, the JDK Project will also deliver new feature releases every six months.

最初,它只基于JDK 7,但自Java 10以来,Java SE平台的开源参考实现是由JDK项目负责。而且,就像对甲骨文公司一样,JDK项目也将每六个月提供新的功能版本。

We should note that before this long-running project, there were JDK Release Projects that released one feature and were then discontinued.

我们应该注意到,在这个长期运行的项目之前,有一些JDK发布项目发布了一个功能,然后就停止了。

Now let’s check out the OpenJDK versions:

现在我们来看看OpenJDK的版本。

  • OpenJDK 6 project – based on JDK 7, but modified to provide an open-source version of Java 6
  • OpenJDK 7 project – 28 July 2011
  • OpenJDK 7u project – this project develops updates to Java Development Kit 7
  • OpenJDK 8 project – 18 March 2014
  • OpenJDK 8u project – this project develops updates to Java Development Kit 8
  • OpenJDK 9 project – 21 September 2017
  • JDK project release 10 – 20 March 2018
  • JDK project release 11 – 25 September 2018
  • JDK project release 12 – Stabilization phase

4. Oracle JDK vs. OpenJDK

4.Oracle JDK与OpenJDK

In this section, we’ll focus on the key differences between Oracle JDK and OpenJDK.

在本节中,我们将重点讨论Oracle JDK和OpenJDK之间的主要区别。

4.1. Release Schedule

4.1.发布时间表

As we mentioned, Oracle will deliver releases every three years, while OpenJDK will be released every six months.

正如我们所提到的,Oracle将每三年发布一次,OpenJDK将每六个月发布一次

Oracle provides long term support for its releases. On the other hand, OpenJDK only supports the changes to a release until the next version is released.

Oracle为其发布的版本提供长期的支持。另一方面,OpenJDK只支持对一个版本的修改,直到下一个版本发布。

4.2. Licenses

4.2. 许可证

Oracle JDK was licensed under the Oracle Binary Code License Agreement, whereas OpenJDK has the GNU General Public License (GNU GPL) version 2 with a linking exception.

Oracle JDK是根据Oracle二进制代码许可协议授权的,而OpenJDK采用GNU通用公共许可证(GNU GPL)第2版,有一个链接例外

There are some licensing implications when using Oracle’s platform. Public updates for Oracle Java SE 8 released after January 2019 won’t be available for business, commercial, or production use without a commercial license, as Oracle announced. However, OpenJDK is completely open source and can be used freely.

在使用Oracle的平台时,存在一些许可方面的问题。正如Oracle宣布的那样,在2019年1月之后发布的Oracle Java SE 8的公共更新,如果没有商业许可,将不能用于商业、商业或生产用途。但是,OpenJDK是完全开源的,可以自由使用。

4.3. Performance

4.3.业绩

There’s no real technical difference between the two, since the build process for Oracle JDK is based on that of OpenJDK.

两者之间没有真正的技术差异,因为Oracle JDK的构建过程是基于OpenJDK的构建过程的。

When it comes to performance, Oracle’s is much better regarding responsiveness and JVM performance. It puts more focus on stability because of the importance it gives to its enterprise customers.

当谈到性能时,Oracle在响应速度和JVM性能方面要好得多。由于它对企业客户的重视,它更注重稳定性。

OpenJDK, in contrast, delivers releases more often. As a result, we can encounter problems with instability. Based on community feedback, we know some OpenJDK users have encountered performance issues.

相比之下,OpenJDK的发布频率更高。因此,我们可能会遇到不稳定的问题。根据社区反馈,我们知道一些OpenJDK用户遇到了性能问题。

4.4. Features

4.4.特点

If we compare features and options, we’ll see that the Oracle product has Flight Recorder, Java Mission Control, and Application Class-Data Sharing features, while OpenJDK has the Font Renderer feature.

如果我们比较一下功能和选项,我们会发现,Oracle产品有飞行记录器、Java任务控制和应用类-数据共享 功能,而OpenJDK有字体渲染器功能

Also, Oracle has more Garbage Collection options and better renderers.

此外,Oracle有更多的垃圾收集选项和更好的渲染器。

4.5. Development and Popularity

4.5.发展与普及

Oracle JDK is fully developed by the Oracle Corporation, whereas OpenJDK is developed by Oracle, OpenJDK, and the Java Community. However, top-notch companies like Red Hat, Azul Systems, IBM, Apple Inc., and SAP AG also take an active part in its development.

Oracle JDK完全由Oracle公司开发,OpenJDK则由Oracle、OpenJDK和Java社区开发。然而,像Red Hat、Azul Systems、IBM、Apple Inc.和SAP AG这样的一流公司也积极参加了它的开发。

As we can see from the link in the previous subsection, when it comes to popularity with the top companies that use Java Development Kits in their tools, such as Android Studio or IntelliJ IDEA, Oracle JDK used to be the more preferred, but both of those companies have switched to the OpenJDK based JetBrains builds.

从上一小节的链接中我们可以看到,当谈到在其工具中使用Java开发工具包的顶级公司的受欢迎程度时,如Android Studio或IntelliJ IDEA,Oracle JDK曾经是更受欢迎的,但这两家公司都已转向基于OpenJDK的JetBrains 构建

Furthermore, major Linux distributions (Fedora, Ubuntu, Red Hat Enterprise Linux) provide OpenJDK as the default Java SE implementation.

此外,主要的Linux发行版(Fedora、Ubuntu、Red Hat Enterprise Linux)提供OpenJDK作为默认的Java SE实现。

5. Changes Since Java 11

5.自Java 11以来的变化

As we can see in Oracle’s blog post, there are some important changes starting with Java 11.

正如我们在Oracle的博文中所看到的,从Java 11开始,有一些重要的变化。

First of all, Oracle will change its historical “BCL” license to a combination of an open source GNU General Public License v2 with the Classpath Exception (GPLv2+CPE) and a commercial license when using the Oracle JDK as part of an Oracle product or service, or when open source software isn’t welcome.

首先,当使用 Oracle JDK 作为 Oracle 产品或服务的一部分时,或者当开源软件不受欢迎时,Oracle 将把其历史上的”BCL“许可证改为开源GNU General Public License v2 with the Classpath Exception(GPLv2+CPE)和商业许可证相结合

Each license will have different builds, but they’ll be functionally identical, with only some cosmetic and packaging differences.

每个许可证将有不同的构建,但它们在功能上是相同的,只有一些外观和包装上的差异。

Also, traditionally “commercial features,” such as Flight Recorder, Java Mission Control, and Application Class-Data Sharing, as well as the Z Garbage Collector, are now available in OpenJDK. Therefore, Oracle JDK and OpenJDK builds are essentially identical from Java 11 onward.

此外,传统的 “商业功能”,如Flight Recorder、Java Mission Control和Application Class-Data Sharing,以及Z Garbage Collector,现在都可以在OpenJDK中使用。因此,Oracle JDK和OpenJDK的构建从Java 11开始基本上是相同的

Let’s check out the main differences:

让我们来看看主要的区别。

  • Oracle’s kit for Java 11 emits a warning when using the -XX:+UnlockCommercialFeatures option, whereas in OpenJDK builds, this option results in an error
  • Oracle JDK offers a configuration to provide usage log data to the “Advanced Management Console” tool
  • Oracle has always required third party cryptographic providers to be signed by a known certificate, while cryptography framework in OpenJDK has an open cryptographic interface, which means there’s no restriction as to which providers can be used
  • Oracle JDK 11 will continue to include installers, branding, and JRE packaging, whereas OpenJDK builds are currently available as zip and tar.gz files
  • The javac –release command behaves differently for the Java 9 and Java 10 targets due to the presence of some additional modules in Oracle’s release
  • The output of the java –version and java -fullversion commands will distinguish Oracle’s builds from OpenJDK builds

6. Other JDK Implementations

6.其他JDK实现

Now let’s take a quick look at other active Java Development Kit implementations.

现在,让我们快速浏览一下其他活跃的Java开发工具包的实现。

6.1. Free and Open Source

6.1.免费和开放源码

The following implementations, listed in alphabetical order, are open source and free to use:

以下按字母顺序排列的实现是开源的,可以免费使用。

  • AdoptOpenJDK
  • Amazon Corretto
  • Azul Zulu
  • Bck2Brwsr
  • CACAO
  • Codename One
  • DoppioJVM
  • Eclipse OpenJ9
  • GraalVM CE
  • HaikuVM
  • HotSpot
  • Jamiga
  • JamVM
  • Jelatine JVM
  • Jikes RVM (Jikes Research Virtual Machine)
  • JVM.go
  • Liberica JDK
  • leJOS
  • Maxine
  • Multi-OS Engine
  • RopeVM
  • uJVM

6.2. Proprietary Implementations

6.2.专有的实施方式

There are also copyrighted implementations:

也有受版权保护的实现方式。

  • Azul Zing JVM
  • CEE-J
  • Excelsior JET
  • GraalVM EE
  • Imsys AB
  • JamaicaVM (aicas)
  • JBlend (Aplix)
  • MicroJvm (IS2T – Industrial Smart Software Technology)
  • OJVM
  • PTC Perc
  • SAP JVM
  • Waratek CloudVM for Java

Along with the active implementations listed above, we can see a list of inactive implementations and a short description of every implementation.

除了上面列出的活动实现之外,我们还可以看到非活动实现的列表以及每个实现的简短描述。

7. Conclusion

7.结语

In this article, we focused on the two most popular Java Development Kits today.

在这篇文章中,我们重点讨论了当今最流行的两个Java开发工具包。

First, we described each of them, and then we emphasized the differences between them. We also paid special attention to the changes and differences since Java 11. Finally, we listed other active implementations that are available today.

首先,我们描述了它们中的每一个,然后我们强调了它们之间的差异。我们还特别注意了自Java 11以来的变化和差异。最后,我们列举了目前可用的其他活跃的实现。