How to Choose the Right Java Version for Your Needs

Choosing a Java Version

Java is one of the top programming languages. One of the choices Java developers often have to make is the Java version to install. The choice becomes complicated due to the multitude of recommendations made in installation procedures. Java could be needed for one or more of the following reasons:

  • Developing end-user Java applications
  • Using frameworks that have a dependency on Java
  • Running software that has a dependency on Java

This article explores the main factors to sort through the rigmarole of choosing a Java version to use.

What Are the Supported Java Versions?

First and foremost, find the supported Java version/s. Typically a support matrix is provided to list the supported Java version and other software. As an example, the OpenJ9 VM provides a matrix for the supported Java Developer Kit (JDK). Or, the supported Java version could be listed separately. As an example, Apache NetBeans 12.0 supports JDK Long Term Support (LTS) releases 8 and 11, and the non-LTS 14. Typically software may include recommendations for the Java version to use based on the version/s the software has been tested with. As an example, WildFly 30 release recommends that Java SE 17 be used:

“Our recommendation is that you run WildFly 30 on Java SE 17, as that is the latest LTS JDK release where we have completed the full set of testing…”

Production or Development and Test?

Is Java to be used in a production environment? Or is it for a development and test environment? The production environment should use a supported LTS version of Java. Java SE LTS releases are 8, 11, 17, and 21. Development and test environments may use a non-LTS version when testing new preview features.

JDK or JRE?

A frequently asked question is whether the Java Development Kit (JDK) or the Java Runtime Environment (JRE) should be installed. If Java development is to be done, the JDK must be installed. As an example, Eclipse IDE provides the option to either install the JDK or just the JRE. Only JRE can be installed if the Eclipse IDE is not to be used for Java Development. JRE is used to run the software itself while JDK is needed to develop Java applications within an IDE. NetBeans 20 includes a note to the same effect:

“The Runtime JDK NetBeans uses does not influence the JDK range projects can use.”

The JDK version needed to run a software could be different from the JDK version that is supported within the same software. As an example, the build tool Gradle supports Java versions between 8 and 21 to run, but "Any fully supported version of Java" for compilation or testing.

Is Bundled Java Provided?

A lot of the software that depends on Java bundles the supported Java version/s with the software. If JDK is not bundled with software that requires Java, the JDK must be installed separately. An example of software that depends on Java but does not bundle the JDK is the Eclipse IDE, which requires Java SDK to be installed. The Eclipse Installer 2023 - 12 R, however, includes a JRE. The Java SE Development Kit 7 Update 80 and NetBeans IDE 8.0.2 Java SE Software Bundle includes both the NetBeans IDE and the JDK. Apache NetBeans 12.0 does not bundle a JDK and provides flexibility regarding the JDK to use based on the Java feature set that a user wants to use.

Which JDK Update?

Another FAQ is, “Why doesn’t the software run even though the correct/required JDK version is installed?” One of the reasons could be that the required JDK update has not been installed. As an example, Apache Lucene 5.3.1 recommends using specific JDK updates as noted in system requirements:

“When using Oracle Java 7 or OpenJDK 7, be sure to not use the GA build 147 or update versions u40, u45 and u51! We recommend using u55 or later.”

Conclusion

This article discussed the process of choosing the Java version to use based on different factors that include supported version/s, environment (production, development, or test), purpose (run software, or develop Java applications), bundled version in software, and recommended version update.

Up Next

February 2, 2024

About the Author

TechWell Insights To Go

(* Required fields)

Get the latest stories delivered to your inbox every month.