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:
- Virtual threads: optimized handling of high-throughput concurrent applications
- Pattern matching for switch statements
- 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...
- Upgrading shouldn't be difficult when using Docker. Why not take advantage of latest features?
- 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.
- 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:
Oracle officially stopped posting updates for Java 8 after September 2016.
Java 11 was released in September of 2018. It is the next major version of Java offering LTS after 8.
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...
- 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.
- 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.
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.
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.