Which Version of Java Should You Use?

Update (Nov 17, 2023):

Java 21 was released in September 2023. It is the latest version to offer long term support (LTS).

Main features of Java 21 include:

  1. Virtual threads: optimized handling of high-throughput concurrent applications
  2. Pattern matching for switch statements
  3. Performance and security updates

LTS for Java 11 has been extended through January, 2032.

It may be worth exploring Java 21 but Java 11 is still widely acceptable and will be supported for years to come.

Update (June 23, 2022):

Java 17 is the latest version of Java available offering long term support (LTS).

While most applications today are using Java 8 or 11, here are some reasons to consider upgrading to Java 17...

  1. Upgrading shouldn't be difficult when using Docker. Why not take advantage of latest features?
  2. Java 17 offers LTS. That means it's the latest version of Java that will still release updates when newer versions are released later on.
  3. Java 17 offers some cool new features that may be worth leveraging for your application....

It's important to note that even in 2022, many applications continue to run on Java 8 and Java 11. While Java 17 offers LTS, it's certainly not unusual if your application is using 11 or even 8.

In 2022, the majority of applications are using Java 8+. This leaves 3 versions offering LTS (8, 11, and now 17).

Update (February 15, 2021): Java 11 remains most recent version featuring long term support (LTS) while Java 15 offers promising new features.

Update (March 29, 2020): Java 14 is the latest stable release and shows promising new features. BUT REMEMBER it will not offer long term support (LTS). For these reasons, LTS support editions are only recommendations for production releases including Java SE 8 and Java SE 11.

Java SE 11 was released in September 2018 and will be the next major version with long term support (LTS).

Java SE 11 OR 17 remains the preferred production standard in 2022. While both 9 and 10 have been released, neither will be offering LTS.Since it's first release in 1996, Java has maintained a reputation for being one of the most secure, reliable, and platform independent languages for computer programming.

Despite its popularity, getting started with Java can be overwhelming. With all the different versions and editions to choose from, it can be difficult to know which version of Java is right for you. In this article, we discuss the relevant versions of Java available including key differences and the version that’s most appropriate for your needs.

Preface: Versions vs Editions

When you download Java, you'll often see different options for "Java SE 7" or "Java EE 8" While the number clearly indicates the version number, the letters tend to confuse newcomers. These letters specify the edition of Java you are using. The most common editions of Java include:

Standard Edition (SE)

The standard edition is the core Java programming platform. It includes all of the core libraries and APIs that every Java programmer needs to be familiar with. For most developers (especially those just getting started) the standard edition is the most appropriate.

Enterprise Edition (EE)

The enterprise edition includes everything found in the standard edition with some additional libraries providing functionality for large-scale enterprise environments. The enterprise edition emphasizes large, fault-tolerant, distributed apps which characterize an enterprise environment.

While EE is appropriate for big business and large scale projects, it's added functionality is not necessary for newcomers or individual developers looking to get their feet wet.

Micro Edition (ME)

The micro edition provides a subset of the functionality that comes with SE, however it includes some additional libraries specific to mobile development. This edition is most appropriate for mobile device Java developers.

Which Version of Java Should I Use?

In today's world, there are 3 versions of Java that you'll commonly run across:

Java 8

Java 8 was released in 2014 and replaced Java 7 as the default recommended download. It's improvements over Java 7 include language level support for lambda expressions, a new DATE/TIME API, and project Nashorn (a JavaScript runtime environment that allows developers to embed JavaScript within Java apps).

Oracle officially stopped posting updates for Java 8 after September 2016.

Java 11

Java 11 was released in September of 2018. It is the next major version of Java offering LTS after 8.

Java 17

Java 17 is the most recent version of Java offering LTS. Released in September 2021, Java 17 offers performance and security enhancements that make it worth the migration. It also has several cool development features worth checking out.

Oracle JDK vs OpenJDK

What is the Oracle JDK?

The Oracle Java Development Kit (JDK) includes the Java runtime environment (JRE) as well as other tools and components for developing Java applications.

When you install Java, you typically install the JDK for both running your applications and developing them.

What is the OpenJDK?

The OpenJDK is a free open source implementation of Java standard edition (SE).

OpenJDK was introduced and established by Sun Microsystems as a promise to make the Java platform open source.

Key differences between the Oracle JDK and OpenJDK

While both OpenJDK and Oracle JDK are created and maintained by Oracle, there are some key differences to note...

  1. Licensing: While OracleJDK is open source, certain releases of Oracle JDK require commercial license. This usually includes professional services like dedicated support but comes with a cost.
  2. Purpose: OpenJDK has the same code base as Oracle JDK. There are many vendors who put their own spin on the OpenJDK by tweaking certain functionality to tailor it for their purpose. For example, the RedHat distribution may enable certain features or use different garbage collector than other peer vendors.

Long story short, these two are technically the same. The real difference comes in using specific vendors who tweak the OpenJDK implementation to suit their own purpose.

Additional Notes

Developer Version vs Product Version

After installing Java, you can run java -version to see which version you have installed. You may see something like java version "1.8.0_71". This is considered the developer version whereas the product version would be 8.0. It's all the same thing...

JDK vs JVM vs JRE

Java requires a runtime environment to execute the code you write. When you download Java, you also get the Java Runtime Environment (JRE). This JRE includes a Java Virtual Machine (JVM) which is an abstract computing machine that enables your computer to run a Java program.

The Java Developer Kit (JDK) is a development environment that you download for developing Java applications. It includes the JRE as well as an interpreter, compiler, and other tools for debugging and development. You'll need the JDK to develop Java applications, but not to run them. This is because the JRE is included with Java installs.

Conclusion

If you're just getting your feet wet with Java then installing either Java SE 8 or Java SE 11 is your best bet. While other editions like EE add extra functionality, the SE has all of the essential libraries you need. While you'll see earlier versions of Java (5,6,7) in the real world, remember that 8 is the actively supported version today. You'll want to install the JDK if you want to write and compile your own Java applications but the JRE is all you need to run existing Java apps.

Your thoughts?

|

Java 8 brought some groundbreaking changes including lambdas, functional interfaces, stream API and other useful features. While Java 11 offered some less noticeable performance improvements, the two both offer long term support (LTS). The vast majority of dev shops are using AT LEAST Java 8+ in production environments these days.

While MOST EVERYONE is using Java 8+, not everyone is using 11 or 17 necessarily. These later versions obviously have improvements over 8 but the fundamental language characteristics remain the same.

In other words, it's REALLY easy to tell when you're not using Java 8 but harder to distinguish if you're using something more recent (11, 17). This is because many of the features introduced with Java 8 (streaming, lambdas, etc) are heavily used today and considered best practice.

If it doesn't hurt your organization to upgrade to the latest version with LTS, then definitely upgrade to 17. Why not???

Well there is actually a reason for not upgrading...like if you have limited devOps resources or bad regression testing or if introducing the update creates a bunch of tech debt or (more commonly) if your infrastructure doesn't easily support it...

Which leads to my final point on Docker. Docker makes it extremely easy to abstract away the environmental headaches from your applications. Using Docker, you can easily pull from a more Java 17 image and swap out Java versions at scale.

|

There is no reason to not be using the latest version of Java LTS in production. Remember that Java is an established and robust language with decades of testing, refactoring, and redesign under its belt. It remains one of the most popular languages used today, especially in enterprise environments.

Java isn't going anywhere and when long term support (LTS) versions are released there is no reason to not upgrade. Versions come out for a reason. Many times developers feel like the difference between Java 8 and Java 17 is negligible. This is because of syntax and not because of developers understanding the performance and security improvements that go into these releases.

Some may point out that existing infrastructure limits their ability to easily upgrade. While this may be true, it definitely points to a bigger problem in your organization. With the advent of containerization, k8, and cloud computing, there is absolutely no reason why Docker containers can't be easily configured and updated to pull from latest images...and with good testing frameworks in place you should be able to know if the upgrade introduces breaking changes fairly quickly...

No excuses! Always use the latest and greatest to protect your code base.

|

Java 11 remains the best option for reliable production deploys in 2021...

Why? It offers long term support and is latest version with LTS :)

|

If you're using < Java 8, professionals will laugh.

If you're using Java 8, professionals will question.

If you're using Java 17, professionals are asking about your experience :).

|

It's 2022 and Java 17 has been around for some time. The question is really IS JAVA 17 worth it?

I have been reading the major updates including some smaller security updates but mostly just deprecating beta / unpopular features released in prior versions.

Can someone please expand on whether or not Java 17 is worth upgrading to?

|

The difference between Java SE and Java EE are negligible into todays programming world. I'm sure some will disagree but we use SE in production and have no issues operating at scale.

|

Using Java 8, 9, or 11 is the best best in 2021...

|

If you're going to update to each LTS patched version, why wouldn't you just update to the latest patch of the latest version? Especially if you're not paying for support from a vendor. OpenJDK has no LTS concept.

|

isn't this kind of an apples and oranges conversation? because OpenJDK is the open source implementation of Java SE platform?

LTS is important because you can use the same version and know it will be supported long term. You don't have to introduce new breaking changes or anything and still get vulnerability fixes and patches..I guess especially important for enterprise??

|

really appreciate this!

|

it's funny how it takes articles like this to get to the bottom of things sometimes. While there are plenty of official java docs out there, this actually tells you (in a nutshell) what version is right for you.

|

If you are using the OpenJDK then you are probably using a certain vendor's implementation of the OpenJDK.

If you are using the Oracle JDK then you are using a version that may require a license.

|

Can someone explain the difference between Java SE and EE..what is the REAL difference there in terms of which one is better and what you get etc.

|

Let's be honest, is the world really a better place with anything past Java 8 :)

|

We use multiple versions of Java in production and don't seem to have any issues. I think it's obviously a good idea to work with something that features LTS...

|

The JRE runs the JVM. The JVM runs your Java application. You build your Java application with the JDK.