OpenJDK for Android in Delphi Development
You may not know this, but Java comes in many flavors and parts. After Oracle acquired Sun Microsystems, they became the official owner of the Java trademark and the main “official” Java distributions.
First off a disclaimer: I’m not a lawyer, nor am I a Java developer. This is a high-level overview of a number of complex issues related to Java, Java development, and licensing. My goal is to give you enough information to move forward and be successful, but I encourage you to do some additional research and consult a lawyer if you need additional information. I know that I will miss details and gloss over important points.
Java is made up of the following parts
- JVM: The Java Virtual Machine is the virtual machine that runs all Java applets. Java applets are usually distributed as Java bytecode in a JAR file. Java bytecode doesn’t run natively on the physical computer. Instead, it runs on the JVM. The JVM is a Just-in-Time compiler (JIT) that converts the Java bytecode into native machine code.
- The two popular flavors of the JVM are Hotspot (the official JVM used by the Oracle JDK) and OpenJ9.
- Technically Android doesn’t have a JVM. Instead, the Java bytecode is converted into Dalvik bytecode and run on the DVM (Dalvik Virtual Machine) or compiled by ART (Android Runtime). Both use .dex files, but ART translates the bytecode into .elf (Executable and Linkable Format) files. This article is mostly focused on the Java desktop side for building Android apps with Delphi, but I wanted to add this aside for clarity.
- JRE: The Java Runtime Environment contains the main libraries a Java applet needs to run, along with the JVM. It includes Java.exe and Javaw.exe that run the applets and other utilities.
- JDK: The Java Development Kit, or the SDK for Java development. The JDK is a superset of the JRE. This is what you use for building Java (and Android) applications, while it also provides everything you need to run Java applets. It includes a number of utilities like KeyTool.exe and JarSigner.exe used to make
- There are 3 variants of the Java platform released by Oracle: Standard Edition (Java SE), Enterprise Edition (Java EE), and Micro Edition (Java ME). This blog post, and most use cases you will encounter, involve the Standard Edition.
Where it gets interesting is with the OpenJDK, a free and open-source implementation of the Java Standard Edition (SE) Platform. It is the official reference implementation of Java SE since version 7. The source implementation is licensed under the GNU General Public License version 2 with a linking exception. [wikipedia] Similar to how Chrome is based on the open-source Chromium project, Java SE is based on OpenJDK.
Anyone, yourself included, could download the OpenJDK source files and create a binary build. There are a number of organizations that do that, and each one has its own spin on licensing, support, and included components. Here are a few (these are binary distributions of the OpenJDK source).
Build | Long Term Support | Permissive License | Pure | Commercial Support |
AdoptOpenJDK / JClarity / IBM Java SDK | Yes | Yes | Optional | Yes |
Alibaba Dragonwell | Yes | Yes | No | Yes |
Amazon Corretto | Yes | Yes | No | No |
Azul Zulu | Yes | Yes | No | Yes |
BellSoft Liberica JDK | Yes | Yes | No | Yes |
ojdkbuild | Yes | Yes | Yes | No |
Oracle Java SE | Yes | No | No | Yes |
Oracle OpenJDK | No | Yes | Yes | No |
Red Hat OpenJDK | Yes | Yes | Yes | No |
Red Hat for Windows | Yes | Yes | No | Yes |
SAP SapMachine | Yes | Yes | No | No |
Source: https://en.wikipedia.org/wiki/OpenJDK |
Oracle provides direct OpenJDK builds, but those builds directly from Oracle do not include long term support or commercial support. For that Oracle wants you to switch to Oracle SE, which does not have a permissive license (Oracle recently changed the licensing on their Standard Edition JDK to charge an annual fee for commercial use). So while OpenJDK source has a permissive license, the binary distribution from Oracle does not have the same license.
That is where AdoptOpenJDK (and others) come in. They take the open-source OpenJDK for Android in Delphi source files and provide a binary distribution with long term support (updates and fixes for old version), a permissive license, and commercial support. AdoptOpenJDK is maintained and backed by the community and a number of large companies including IBM, GoDaddy, Microsoft, and Red Hat.
RAD Studio doesn’t directly depend on Java, but if you are using the Android SDK to target Android then you are using it. The current RAD Studio installer offers you the option to install the standard Oracle JDK if you don’t already have one installed. In the future (approximately 10.4.x timeframe), Embarcadero is planning to change the default option to install AdoptOpenJDK for OpenJDK for Android in Delphi
The decision for which JDK and JRE to use OpenJDK for Android in Delphi is up to you.