Confusion on Java

Raymond Meester
5 min readJun 27, 2019

Which version to use?

In the song “Land of Confusion” by Genesis, the band questions the wisdom of world leaders during the cold war. During this time there was a lot of going on and it was hard to get things clear.

In the world of code there is also confusion on the island Java. Changes in license terms and versioning got organizations and developers confused. Often these organizations ask their developers what they should do. This a rather technical and complicated discussion. What to recommend? How to get things clear?

Current versions

Versioning of Java has been changed over the years. So this is a confusing place to start. First there is a technical version number like 1.8. For marketing purposes the “1.” was left away. So java 1.8 was marketed externally as Java 8. From versioning 9 the external number was completely left away also in the technical number.

The current supported versions:

6 / 1.6.0_221

7 / 1.7.0_221

8 / 1.8.0_212

9 / 9.0.4

10 / 10.0.2

11 / 11.0.3

12 / 12.0.1

Note that the minor version number scheme also changed between versions. It took too much time to cover all scheme changes here (also because they’re ridiculous). Also note, that until Java 8 there were only long term support versions (supported for years), but there are now intermediate versions which adding new functionality.

So, now lets get a closer look at the different versions:

JRE Version

12 Latest Intermediate version

11 Latest Long Term Support version

10 Previous Intermediate version

9 Old Intermediate version

8 Previous Long Term Support version

7 Old Long Term Support version

6 Old Long Term Support version

Now Java 13 is already around the corner. So what version should one use? Here are some general rules. Not recommended anymore are all old versions Java 6, 7 and 8. Those versions are outdated. Also, version 9, 10, 12 and 13 are not recommended as intermediate versions have a short support cycle.

So the current recommended version is Java 11.

Why Java 11?

There are some great options available for Java 8, but should we upgrade to version 11? This is really a good time to investigate this. Java mostly has good backwards compatibility and Java 11 is a long-term support release with all the latest features.

The major features since Java 8 are:

Java 9

Java was the first intermediate version with a lot of new features:

  • Java Modules (The “Jigsaw” project): These modules help especially in large projects with many Jar files where developers end up in classpath and class loading problems (aka JAR Hell).
  • JShell: Shell to run and test code in live mode.
  • Garbage Collector: New default garbage collector called “G1” which offers better performance.
  • HTTP 2.0 Client.
  • Process API: libraries to interact and get information on OS processes.

Java 10

  • Local-Variable Type Inference:

This mean you can now declare variables with “var”.

Old way:

HashMap<String, String> map = new HashMap<>();

New way:

var map = new HashMap<String, String>();

  • Docker: The JVM now knows when it is running inside a Docker Container.
  • Root certificates are also available in OpenJDK (Before OpenJDK had no certificates build in)

Java 11

  • Single file applications. When your Java application is only one file, you can now do:

java -classpath /home/foo/java Hello.java

This used to be two steps:

javac -classpath /home/foo/java Hello.java

java -classpath /home/foo/java Hello

  • Option to turn off the Garbage collector (for example for performance testing)
  • Support for Unicode 10
  • Support for TLS 1.3

Java Developer Kit’s

The Java developer kit contains the JVM to run Java programs and some developer tooling. As mentioned earlier, most are organizations are still using Oracle JDK 8 (aka 1.8). It’s stable and has long term support. Note that “1.8.0_201-b09” is the latest Java SE 8 version of Oracle for business use (for newer versions you need to pay).

What if you don’t want to pay?

The alternatives are:

  1. Use OpenJDK (version 8 or 11)
  2. Use Amazon Correto JDK (version 8)
  3. Use SAP Machine JDK (version 11)
  4. Use Red Hat OpenJDK (version 11)
  5. Use Eclipse OpenJ9 (version 11)
  6. Use IBM JDK (version 11)
  7. Use Oracle GraalVM (CE)

In the above diagram most JDK implementations are based on OpenJDK. This is a free and open-source implementation of Java SE. Previously you had to build it yourself and it came without root certificates. Now you can download a pre-build version from here:

https://adoptopenjdk.net/

Which JDK to use?

The latest OpenJDK versions also includes root certificates. In general version 11 of OpenJDK is now recommended to use. Other JDK’s are only to choose to ensure long term support by a major IT company like Oracle, Amazon, SAP and Red Hat. Last three have less strict license terms than Oracle. IBM is recommended when working with certain (IBM) technologies.

Correto is an OpenJDK variant created by Amazon with long term support until 2023. Version JDK 8 is now available and Correto JDK 11 is available from April 2019.

SAPMachine is an OpenJDK variant created by SAP. Version JDK 11 is now available.

Red Hat also offers an official supported OpenJDK version which claims to be similar to OracleJDK. More information you can find here.

Eclipse OpenJ9 is an OpenJDK build optimized for small footprint and start up times. Website is on Github.

IBM offers a JDK that works with IBM technologies such as z/OS (mainframes) and AIX.

Oracle offers also a new variant called GraalVM. This VM is still experimental.

Beyond Java 11

So for production we use (Open)JDK 11, but we can check some new developments.

Java 12

Java 12 (release march 2019) improved Switch statements. Old way:

int numberOfLetters;

switch (fruit) {
case PEAR:
numberOfLetters = 4;
break;
case APPLE:
case GRAPE:
case MANGO:
numberOfLetters = 5;
break;
case ORANGE:
case PAPAYA:
numberOfLetters = 6;
break;
default:
throw new IllegalStateException (“Wut” + fruit);
}

New way:

int numberOfLetters = switch (fruit) {
case PEAR -> 4;
case APPLE, MANGO, GRAPE -> 5;
case ORANGE, PAPAYA -> 6;
}

Also new is (another) experimental Garbage Collector (pausing independently from heap size) and a suite to test performance.

Java 13

Expected in fall of 2019 is version 13. This offers following new functionality:

GraalVM

GraalVM is also based on OpenJDK, but it offers another way of compiling. It also adds additional runtime support for other languages like Javascript or Ruby. Goal is better performance, reduced start time and support for more languages. Oracle offers a paid Enterprise versions which is considered production-ready from version 19 (may 2019).

Enjoy your visit

Though Java is allready 25 years old, there is still a lot going on. Hopefully this overview made things a little clearer when visiting the island.

--

--