A few weeks ago, I posted about the benefits of upgrading from Java 8 to Java 17. Whether you decide to upgrade versions or not, there’s another question that you also need to ask: “Which Java JDK distribution should I use?”
OpenJDK Project
Almost all Java SE JDKs are based on the OpenJDK. This is the open source reference implementation (RI) of the Java SE specification. The OpenJDK project ships a feature release with a new major version number every six months, in March and September. There are also quarterly updates.
The original plan was that, every three years, the September release would be a Long Term Support (LTS) release. The LTS release would get updates for at least the next three years. The current LTS releases are Java 8, 11, 17 and 21. There was a three year gap between Java 11 and Java 17, but only a two year gap between Java 17 and Java 21.
We can plan on LTS releases being released every few years like clockwork. It’s easy to plan application upgrades around these releases.
Binary Distributions
The OpenJDK project provides limited binary builds of its source code. Most and better binary builds are provided by a number of different vendors. These distributions are built from the same source code, but they differ in which Java versions, operating systems and architectures they support. The licenses and update intervals also differ. Some vendors provide additional security fixes, performance enhancements, enterprise features and/or commercial support.
Most of the licences are the GNU General Public License, version 2, with the Classpath Exception (GPLv2+CE).
There are lots of options for OpenJDK distributions. Current vendors include:
- Oracle OpenJDK (limited free, GPL-licensed binaries at jdk.java.net)
- Oracle JDK (Oracle No-Fee commercial license)
- Adoptium Eclipse Temurin (formerly AdoptOpenJDK)
- Amazon Corretto
- Alibaba Dragonwell
- Azul Zulu (free)
- Azul Platform Core and Platform Prime (formerly Azul Zing) (commercial)
- BellSoft Liberica JDK
- GraalVM (a very exciting project, but radically different to all the other JDKs)
- IBM Semeru Runtime (based on the OpenJ9 VM instead of the HotSpot VM)
- Microsoft Build of OpenJDK
- Red Hat OpenJDK
- SapMachine
Which vendor and distribution to use? Decisions, decisions…
Recommendations for choosing your Java JDK
The WhichJDK website offers opinionated recommendations, most of which I’ll summarise here.
-
Their top recommendation is to use the latest LTS version from Adoptium Eclipse Temurin. The Adoptium Working Group consists of major companies with a strategic interest in Java, including Red Hat, IBM, Microsoft, Azul and the iJUG (Internet Java Users Group).
-
Other recommended distributions are:
-
Azul Zulu Builds of OpenJDK. (I personally use Zulu JDKs, and have had no problems with them.)
-
BellSoft Liberica JDK builds.
-
Amazon Corretto builds are good especially if you run Java applications on Amazon Linux 2 in AWS.
-
They suggest that you only use the other distributions if you have specific needs or are running on specific software and/or hardware:
-
Use Azul Platform Prime if you need very short GC pause times. Do not use it in production without a commercial license.
-
Use IBM Semeru Runtime only if you know that you need the OpenJ9 Virtual Machine.
-
Use Microsoft Build of OpenJDK only if you run Java applications directly on Azure.
-
Do not use OpenJDK builds by Oracle, particularly if you only use LTS versions. These builds are only updated for a period of six months after release.
-
Do not use Oracle Java SE Development Kit (JDK) unless you consult a lawyer first. These builds have changing and/or vague licenses.
-
Use Red Hat OpenJDK only if you are running Java applications directly on Red Hat Enterprise Linux.
-
Use SapMachine only if you are running Java applications on SAP servers.
-
Do not use Alibaba Dragonwell.
-
-
To LTS or Not To LTS?
The best version of Java is always the latest that works. Newer Java versions are generally faster because of better GC algorithms and heuristics, better JITs, and better library code.
But with that said, many developers only follow the LTS releases, without updating their JDK versions to any of the interim STS (short term support) and MTS (medium term support) releases.
You should probably treat a non-LTS version as a beta release or a feature showcase. Don’t run it in production unless there’s a new Java feature that you absolutely have to use because it’s going to save you lots of development time, or your application code is highly unlikely to run into any support problems.
You can decide if you want to stay with the latest LTS version, or if you go with the latest feature releases and upgrade every six months. Both options are fine, but if you’re undecided, rather stick with the latest LTS version.
OpenJDK seems to recommend that new projects use the newest JDK, and to upgrade each time a new version comes out. In reality, businesses and corporations will struggle to do this due to governance rules, project deadlines, and QA and testing issues.
Java 8, 11, 17, and 21 are all LTS. I wouldn’t recommend using any interim versions for production code.
Conclusion
As stated earlier, there is excellent coverage along with opinionated recommendations on which JDK distribution to use at https://whichjdk.com/.
Detailed technical information on all Java releases is available at The Java Version Almanac.
Was this interesting? Please share your comments, and as always, stay safe and keep learning!