Recently, we were asked to ensure that a course we were giving used Java 8. This may not seem that strange of a request until you realise that Java SE 8 (aka "Java 8") was released in March 2014 and that the current Java version, released in March 2020, is Java 14. This raises the question, why did the client want to use such an old version of Java?
There are of course many reasons why an older version of a programming language might be required, however the request from this client to use Java 8 in particular is far from unique. So why this fixation on Java 8?
Indeed, since Oracle decided to change the frequency of Java releases, as well as its attitude towards Long Term Support, many organisations have decided to stick with Java 8 despite numerous newer releases. One survey from February 2020, found that 64% of developers reported that Java 8 remained the most often used Java release.
Below we outline some of the reasons why an organisation might choose to stay with an older version of Java, rather than rushing to adopt a shiny new version.
One of the key reasons why Java 8 is still so popular is that it is an LTS (or Long-Term Support) version. Unfortunately, not all version of Java are LTS versions! Since this policy was introduced only Java 8 (2014) and Java 11 (2018) have been designated as having LTS. This means that all intervening releases, including Java 14 and the planned Java 15 (September 2020) do not have LTS.
From a commercial point of view no organisation should be considering putting a system into production that relies on a version of Java that does not have LTS. It is also worth noting that, although Oracle ended free support for Java 8 in January 2019 for commercial use (and will end it for personal use in December 2020), it is possible to pay for commercial support for Java 8 until December 2030.
Back in 2018 Oracle announced fundamental changes to the way in which Java is licensed. From 2019, if an organisation makes commercial use of Java 11+ then they must pay for it. This means that moving from Java 8, to the next LTS version Java 11, could have significant financial or legal implications. In some cases, this has certainly been a limiting factor in the adoption of Java 11.
Oracle JDK v OpenJDK
An alternative to the official Oracle JDK (Java Development Kit) is the OpenJDK. OpenJDK is Oracle’s open source version of the JDK.
Although there has long been an open source version of Java; from Java 11 onwards Oracle has officially provided the free to use, open source, OpenJDK. This version of the JDK is released under the open source GNU General Public License (GPL) v2. OpenJDK is a production ready JDK which is also an official reference implementation of the Java Standard Edition (SE) specification. It is the responsibility of the JDK Project with input from Oracle along with organisations such as Red Hat and IBM, etc.
This is Oracle’s commercially supported version of Java. It is built from the OpenJDK sources. In the past there were differences between the open source version of Java and Oracle’s commercial version, due in part to the latter’s use of closed source or proprietary elements. However, since Java 11 the intention is that the two versions are “essentially identical” apart from some cosmetic differences.
Due to historical differences between the Oracle JDK and the OpenJDK, as well as differences in support policies (the OpenJDK only supports changes to the most recent release); some organisation have been reluctant to adopt the OpenJDK or have been confused about the two versions (not least due to the very similar names). In addition, there are other OpenJDK versions, such as Amazon Corretto and AdoptOpenJDK, which can further muddy the waters.
Commercial organisations often prefer stability over change and prior to Java 9 the frequency with which Java changed was quiet low. Indeed, there was a period of 3 years between the release of Java 7 and Java 8. However, since Java 9 the rate of change has increased with a new version every six months (usually March and September). This means we will have gone from Java 9 to Java 15 in just 3 years. Each of these releases introduces new features, deprecates (or removes) other features and often introduces changes to how programs are executed. This can mean that organisations are nervous of adopting newer versions as they may be introducing additional technical challenges every six months.
Some of the above may explain why organisations should only use a Java LTS version for production systems. The focus is therefore naturally upon Java 8 and 11. This perhaps raises the question ‘should they switch to Java 11?’.
The following are four reasons why they should:
1. Oracle no longer supplies free support to Java 8
Free support for commercial use of Java 8 ended in January 2019. However, support for Java 11 is available via the OpenJDK using Amazon Corretto or AdoptOpenJDK until 2024. Although it should be noted that extended support for Java 11 is only available until September 2026 (unlike Java 8 which has extended support until December 2030).
Modules were introduced in Java 9. They provide an effective way to encapsulate a body of code and its dependencies. This avoid the problems associated with a single classpath and library version hell!
3. VM Versions
Significant changes have been made to the Java runtime environment (or JVM) between Java 8 and Java 11. These changes can significantly improve the performance of an application (see GraalVM and the Z Garbage Collector).
4. Local variable type inference
In many modern programming languages, including Kotlin and Scala, the compiler is able to infer the type of a variable using type inference. This simplifies the specification of variables and reduces the amount of boiler plate code. This feature was introduced in Java 10 via the var keyword and allows the following line of code:
HashMap<String, String> data = new HashMap<String, String>();
To be re written simply as:
var data = new HashMap<String, String>();
In summary there are several reasons why many organisations are still using Java 8. Going forward they may choose to use Java 11, as this is the current LTS version, or may decide to wait it out until Java 17 (the next LTS version) is released.
...then you will love our Java training courses, where you'll gain solid hands-on experience, guided by an industry expert. All our Java classes are available to attend online as virtual instructor-led training courses.