The Importance of Upgrading Java – A Comprehensive Guide

Estafet consultants occasionally produce short, practical tech notes designed to help the broader software development community and colleagues. 

If you would like to have a more detailed discussion about any of these areas and/or how Estafet can help your organisation and teams with best practices in improving your SDLC, you are very welcome to contact us at enquiries@estafet.com 

Introduction

Java is a popular and versatile programming language that has been in use for nearly 30 years and is still going strong today. It is a mature language that has demonstrated its value continuously over the years. From prototyping simple projects to developing complex systems, Java is used by big and small businesses alike. A wide range of applications are written in Java, including mobile & desktop apps, web & application servers, games and more.

Java is subject to frequent enhancements and is constantly evolving as a programming language: new LTS (Long-Time-Support) versions roll out every 2 years. This article will explain why it’s essential to keep up with new versions of Java and will outline the benefits of doing so, including:

  • Access to new features
  • Security updates
  • Performance enhancements
  • Support
  • Compatibility with third-party frameworks
  • Ease of migration towards an even more recent Java version
  • Boost of morale among Java dev employees, etc.

Lastly, I will also list some static analysis and AI tools that can help you with migrating to a higher JDK like Java’s jdeprscan, IBM’s Migration Toolkit for Application Binaries and the recently introduced AI-powered Amazon Q Code Transformation.

Java Versioning and Adoption

Since 2017, Oracle has established a specific release train for new versions of Java: one feature release comes out every 6 months. Every March and September, the Java community receives a new release, with LTS versions arriving every 2 years. The latest LTS version is Java 21 which was released in September 2023. Although the JCP Program is working hard on pushing the Java ecosystem forward, some companies, especially big enterprises, are reluctant to upgrade. According to JetBrains’ annual Developer Ecosystem Survey taken in 2023 among more than 25,000 developers around the globe, 50% of respondents who chose Java as one of their primary programming languages regularly use Java 8 with 45% going to Java 17 and 38% to Java 11:

50% of respondents regularly use Java 8

Source: JetBrains’ 2023 Dev Ecosystem survey

These are actually optimistic results compared to JetBrains’ 2022 and 2021 surveys when Java 8 was used by 60% and 72% of respondents respectively. Another survey shows slightly different results: according to Azul’s 2023 “State of Java” Report, Java 17 and Java 11 usage is fortunately already ahead of Java 8, but the latter is still at a sizable 40%. Regardless, we are seeing a steady shift towards more recent Java LTS versions among developers. It is also pleasant to see that a larger percentage are using the more recent Java 17 rather than 11. A significant number of respondents however are still using the nearly decade-old Java 8. Why are some companies so reluctant to upgrade?

Each company probably has its own unique motives, but I will try to list some of the most likely reasons:

  • “If it’s not broken, don’t fix it”: companies that have used Java 8 for many years have trust in this particular JDK version. It has stood the test of time and gives a sense of stability. In fact, migrating to a new version could break an existing integration or a dependency to an old library and technical staff would have to find solutions to problems that didn’t even exist.
  • “We can’t spare the time and effort for it”: migrating to the latest major Java release could be a significant effort that increases the bigger the gap between versions is. Besides for implementation, a lot of effort would be needed for regression testing as well. In today’s dynamic landscape, product owners and interested parties might not justify such an upgrade – they would rather develop and ship new features and implement bug fixes as soon as possible than spend time and effort upgrading Java.
  • “We have a lot of legacy systems”: large enterprises sometimes use third-party software that may be bound to an older version of Java. Even smaller companies might be tightly coupled to a legacy library that is no longer maintained. Sometimes it’s hard or impossible to upgrade/find replacements for legacy systems or libraries.
  • “We don’t want to risk it”: start-ups are more likely to adopt more recent Java versions, while large enterprises usually take things slowly. Start-ups use cutting edge technologies and tend to “move fast and break things”, while enterprises often upgrade their technologies only when they have no other choice.

These, and more, are very valid concerns. Upgrading to a newer Java version is a decision that requires a company-wide discussion and should not be taken lightly. However, as the old proverb says, “nothing ventured, nothing gained”: upgrading Java can also bring you many benefits, some of which are listed below.

Benefits of Updating Java

Whether you are using Java 8 or you have already moved on to 11 (or higher), every item from the below list will still be relevant to you. Remember that Java currently follows a pre-set release train and keeps evolving constantly. You should not be thinking about an upgrade as a one-off thing, but rather as an activity you should be doing continuously, possibly every couple of years. If you plan on moving to Java 11 just to use it for another decade, then Java 11 will become the new Java 8 and you will be stuck in the same loop.

Here are 7 reasons why you should consider upgrading your Java version:

  1. Taking advantage of new language features

One of the main reasons for Java’s current 6-month release cadence is the ability to deliver new features in a timely manner. Java 8 is undoubtedly the most revolutionary release in Java history (adding features like lambda expressions & Stream API, functional interfaces, the Optional class and default methods, to name a few), but later versions don’t fall behind in continuing to modernise and enhance the language. Some key post-Java 8 features include:

  • Records (Java 17): a Record is a special type of class that helps create immutable plain data objects.
  • Virtual threads (Java 21): lightweight threads that reduce the effort of writing, maintaining, and debugging high-throughput concurrent applications.
  • Java Platform Module System (Java 9): JPMS is a module system that can group Java packages into modules.
  • Private methods on interfaces (Java 9): this feature enables non-abstract methods of an interface to share code between them.
  • Enhanced switch and pattern matching with records, switch and if (Java 14, Java 21): provides a concise way of testing whether switch expression/record objects have a particular structure.
  • Sealed classes and interfaces (Java 17): this feature enables classes and interfaces to restrict which other classes or interfaces may extend or implement them.
  • Text blocks (Java 15): text blocks are an easy way to declare automatically formatted multi-line strings in Java.

Some exciting new features are now in preview in Java 21, including:

  • Structured concurrency
  • String templates
  • Unnamed classes and instance main methods
  • Unnamed variables and patterns

These are just some of the many additions that were introduced in recent years. Many new Java language features are being worked on as we speak. Leveraging these new features can improve developer productivity, code readability and overall code maintenance. Receiving regular language enhancements is essential for Java to remain a modern programming language and utilising them should be common sense.

  1. Security updates

Using a more recent Java version does not only allow you to take advantage of new language features, it also provides access to bug fixes and security updates. Large enterprises usually have dedicated cybersecurity teams who take steps in safeguarding the company from malicious attacks – for example, by establishing a firewall or by monitoring network activity. Despite their best efforts however, no business is immune to software CVEs (Common Vulnerabilities and Exposures). We were reminded of this fact in December 2021 when the Java world was shaken by the Log4j vulnerability.

One way to deal with CVEs is to apply patches or security updates that correct these vulnerabilities. It is always recommended to keep your software up-to-date, and that should include Java. While your Java applications may be protected by your organisation’s VPN and firewalls, using a higher version of Java will add an extra layer of security, further ensuring the safety of your internal apps.

Critical vulnerability and security fixes are usually backported to older versions of Java as well. Older LTS versions do receive security updates a few times per year. If you’re using such a version, you might already be doing these updates instead of directly upgrading to a higher version. Doing a mere update instead of a version upgrade however will not give you access to the most recent language features.

  1. Enhanced performance

In addition to new features and security updates, with every new release, the engineers that work on the JDK also use the opportunity to modify or refactor the Java codebase to boost performance. Code optimization and garbage collection improvements are things that are seen in virtually every new Java release.

Garbage collection is a well-known factor that can impact performance. There have been many changes in this regard since Java 8: new garbage collectors have been introduced and improved (like the Garbage-First G1 collector), while old ones have been dropped altogether (like the Concurrent Mark Sweep GC which was removed in Java 14). Although the JVM automatically chooses a GC depending on hardware, Java users are encouraged to explore different garbage collectors and see which one is most performant for their specific scenario. Using a newer Java version will help you take advantage of recent GC enhancements.

Programmers working on the JDK also do code optimizations that improve performance. To mention some examples, Java 21 has improved serialisation performance by 7%. This may not look like much, but serialisation is used in many apps and frameworks (as well as the JDK itself). URLEncoder performance also got boosted by 12%.

JDK performance will surely be enhanced in future Java versions as well and if you are keeping up with them, you will get these benefits out of the box.

  1. Support

Supporting old versions of software products while continuously releasing new ones adds unneeded overhead and companies tend to just “retire” old software (for example: Windows 8.1 support ended in January 2023 and Windows 7 support ended in January 2020). In fact, Java is no exception to this tendency: as of 2018 and 2022 respectively, Oracle no longer provides support for Java 6 and 7. What this means is that you can continue to run software with these versions, but you will not receive any updates or security patches which increases risk and makes your applications vulnerable. Third-party vendors like Azul provide paid support for older Java versions, but this is hardly an ideal scenario. 

Java 8 is the next one in line: Oracle Premium Support for Java 8 ended in March 2022 and extended support will end in December 2030. While Java 8 support may or may not be extended beyond 2030 (everyone is aware that many companies still rely on Java 8), it is better to be prepared and plan for the future.

  1. Compatibility with third-party software

Since the JDK is at the heart of every single Java library or framework, be it open source or proprietary, if you’re using an older version of Java, sooner or later there will come a time when you will not be able to take advantage of new library and framework features. If your dependencies require a higher version of Java than what you already have, if you want to use these dependencies, you will have no choice but to upgrade.

It is natural for teams to drop support for what they consider outdated in order to evolve their project. Java 8, being almost a decade old, is already a version that is considered legacy among many teams. Spring Boot 3 (along with Spring Framework 6), which was released in November 2022, requires Java 17 as a minimum version and users who want to use these versions are obligated to upgrade their JDK. Version 5 of Mockito, the popular open source mocking framework, is also dropping support for Java 8 and currently requires JDK 11 as a minimum. The well-known ORM solution for Java, Hibernate 6, also has a baseline of Java 11. 

 If you cannot update the libraries and frameworks you use, not only will you be unable to access bug fixes and new features, but your product may also become more vulnerable. By not upgrading Java, you might find yourself in a situation where your applications can become nested dolls of possible vulnerabilities that you will not be able to address.

  1. Ease of further migration

Upgrading to a new Java version (especially if you’re starting from Java 8 or below) might be a substantial effort, but you must consider that after you have done the heavy lifting once, migrating to future versions would be much easier.

It’s true that newer Java versions deprecate or move packages around which breaks backward compatibility with previous code, but that’s only significantly noticeable if you’re taking a huge leap between versions. In fact, if you’re upgrading from Java 8, one approach would be to take smaller steps through versions so as to not be bombarded with a decade worth of changes all at once.

Once you’ve upgraded to a more recent Java version, because of the 6-month release train, you can actually try out newer non-LTS JDKs and see how that affects your application. One of the reasons for releasing new feature versions of Java twice a year is for the Java community to try them out and give feedback. This way you can experiment with new features, see what APIs are deprecated or what packages were moved – all this will help you assess and even estimate a possible upgrade to the next LTS version when it comes out.

  1. Developer satisfaction & self-esteem

Last on this list, but certainly not least, is the overall satisfaction and morale of tech staff. Most developers prefer not to work with older technologies if they can help it. According to a 2021 Stack Overflow blog article about a survey among 500 developers, when asked why they are looking for/open to a new job, 39% of respondents said that they wanted to work with new technologies:

Source: Stack Overflow blog, December 2021

According to the results, wanting to work with new technologies is the second highest reason for people looking for a new job opportunity after “better salary/pay”. Developers are usually naturally curious and many of them keep up with recent news in the Java world. It would be a waste if they can’t fully apply their skills at their workplace.

Using modern technologies is also a good motivator for retaining or gaining new technical staff. If you want to be relevant on the market and advertise yourself as a competitive business to job candidates, you need to be prepared for answering the inevitable interviewee question: “What Java version do you use?”

Conclusion

This article has described several benefits of upgrading to a newer Java version including: access to new features and security updates, enhanced performance, support, compatibility with third-party software, ease of further migration and developer satisfaction.

There may be valid reasons for your organisation to use an older Java version. Upgrading Java, especially in a big enterprise, is not an easy decision to make. However, with more LTS Java versions coming out every 2 years, you should take the time and think about an upgrade sooner rather than later. Popular open source projects like Spring Boot, Hibernate and Mockito have already made the decision to drop Java 8 support in future releases and many businesses have also decided to make the change and upgrade to a higher LTS version like Java 17.

If you have made the decision to upgrade, there are many tools to help you and make the task easier. Java itself offers a static analysis tool called jdeprscan (“Java Deprecated API Scanner”) which produces a report on your application’s use of deprecated JDK API elements. IBM also has a static analysis tool that can help with migrating to a higher Java version: the Migration Toolkit for Application Binaries.

In addition to static analysis tools, generative AI-powered solutions designed to help you with Java migration are also emerging: Amazon has very recently introduced Amazon Q Code Transformation, an AI tool that automates common language upgrade tasks. It can create a transformation plan for upgrading the Java version of your code which includes updating dependencies, building against a target Java version of your choice and generating code changes for you to review and accept. As of writing this in December 2023, Amazon Q is still in preview release and can only upgrade Java 8/Java 11 code to Java 17 code, but internal Amazon results look very promising:

Source: Amazon Q Code Transformation

Java 8 brought a lot of new features and changed the way we write Java code back in 2014. A lot has happened since then and now there are many tools in the toolbox that can help you migrate your applications to a higher Java version. If your organisation has not yet seriously considered a Java upgrade, now is the best time to do so – the sooner, the better!

By Yoana Ivanova, Consultant at Estafet

Stay Informed with Our Newsletter!

Get the latest news, exclusive articles, and updates delivered to your inbox.