Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Versions and Compatibility

I am confused about different versions.

I am a beginner, so forgive me if this is obvious, but... I am using JDK 20, which I see has some features in testing. On a separate computer, to test JAR files, I googled and downloaded the most recent version of Java, version 8u361, but not the JDK. This appears to be what someone who was not a developer would download.

My exported JAR files will not open and say that they were made using a more recent version. I was able to solve this problem by scaling back and using JDK 1.8, which allows java 8u361 to open them. Am I misunderstanding something. The most recent version of Java SE can't run anything that I make with JDK 17, 18, 19 or 20? I looked at a compatibility chart and couldn't reconcile this questions.
What is the JDK to Java SE equivalence?

like image 338
Wesley Peart Avatar asked Oct 29 '25 01:10

Wesley Peart


1 Answers

Later Java runs earlier apps

You said:

JAR files will not open and say that they were made using a more recent version

An implementation of Java will be able to run most any Java app built with earlier versions of Java.

👍🏽 For example…

If you compile your app using Java 8, you will almost certainly be able to run that app with Java 8, Java 9, Java 10, Java 11, and so on, all the way through to today’s Java 25.

This compatibility is one of the highest priorities for the Java team at Oracle, and a large part of Java’s success. Breaking changes have been kept to an absolute minimum. “Move fast and break things” is not their motto, just the opposite.

👎🏽 Going the other direction…

If you compile your app using Java 20, you will not be able to run that app with Java 8, Java 9, Java 10, and through to Java 19. A later version of Java and its compiler will be using features that did not exist in those earlier versions. So, of course, older runtimes cannot execute later apps.

👉🏽 If you compile with 20, you need to run with 20 or later (20, 21, 22, 23, 24, 25+).

Java Release Train

Java 25 is current now in 2024-09.

Java releases arrive on a regular schedule, like a train, every six months, Autumn & Spring. Any feature not yet production-quality gets bumped to the next release, like a passenger missing a train boards the next one.

LTS

Versions 8, 11, 17, 21, & 25 are designated as long-term support version. These versions continue to see updates over many years. The other versions in-between receive updates only for several months.

JDK & JRE

You said:

but not the JDK. This appears to be what someone who was not a developer would download.

A Java Runtime Environment (JRE) is an implementation of the Java SE specifications, a complete Java platform, with all the software you need to execute an app written in a JVM-compatible programming language such as the Java programming language, Groovy, Scala, and more.

This JRE software consists primarily of a Java virtual machine (JVM) which executes the Java bytecode of a JVM-based app, and adapts that app to the host operating system. A JRE also provides an implementation of the standard Java class libraries. And you get a few tools: jfr, jrunscript, jwebserver, keytool, rmiregistry (docs).

A Java Development Kit (JDK) is a JRE plus tools necessary to write Java apps. These tools include a compiler, a debugger, a profiler, a Javadoc (documentation) processor, and more.

So:

  • For you to write a Java app, you need a JDK.
  • For your customers to run your app, they need a JRE.
JRE JDK
Runtime engine: JVM, classes, & tools JRE + compiler + more tools

Both JDKs & JREs can be obtained from any of several vendors listed below.

Rolling compatibility

An app compiled for a lower numbered version of Java can be run on the same or higher numbered version of Java. (Unless using a feature later removed, a rare occurrence with Java.)

So yes, an app built for Java 8 can run on Java versions 8, 9, … 17, 18, 19, and 20. But not the other way round. An app built for Java 18 can only be run on Java versions 18, 19, and 20.

JDK vendors

You can obtain a JDK or JRE from any of several vendors.

These vendors include, in no particular order:

  • Amazon
  • Adoptium (the Eclipse Foundation)
  • SAP
  • BellSoft
  • Microsoft
  • Azul Systems
  • Oracle
  • Red Hat
  • IBM

… and more.

If you have no reason to choose a particular vendor, then I suggest starting with Adoptium, a joint effort across the Java community.

Be sure to study the vendor’s legal licensing terms.

Tip: One very convenient way to obtain a JDK/JRE product from a subset of those vendors is by using SDKMAN!, a simple console app.

Every JDK release is production-quality

You said:

JDK 20, which I see has some features in testing

Any feature available by default in Java 20 (or any version) is entirely ready for production use. Each release from any of the JDK vendors has gone through extensive testing.

Any feature not ready for production, because the details may change, is marked as either incubating or preview. These features are never available to you by default. So you cannot use them unwittingly. You have to go out of your way to activate such features. Note that such features are complete in that they have been fully built and tested — they are not “half-baked”. So these features can be used if you so choose, but come with the caveat that they may change or even be withdrawn in the next version.

So understand:

  • Every new release of every JDK version is fully ready for production use.
  • Java 20 was fully ready for production use.

(Java 20 no longer received updates a few months after the successive version 21 shipped.)

Every JDK is an implementation of Java SE spec

You said:

What is the JDK to Java SE equivalence?

Java SE is a set of specifications published by Oracle Corp.

”Java” (and ”Java SE”) is a trademark owned by Oracle Corp. Available for use only with permission by Oracle.

A JDK is an implementation of the Java specs, plus a compiler and other tools for development and administration.

Some JDK products use the trademark “Java”, but only if permitted by Oracle.

OpenJDK is an open-source project developing a codebase for implementing Java across several chip architectures and operating systems. Many companies and individuals contribute. These include Oracle, IBM, Apple, and others. Many JDK products are based largely, if not entirely, on the OpenJDK codebase.

The term “OpenJDK” may be confusing. Oracle permits any JDK vendor to use the term within the name of their JDK product. Some vendors do, and some do not. Just be clear that the OpenJDK project produces only source code, not binaries or installers. To obtain binaries or installers, choose a vendor from the list seen above.

Java spec number = JDK number

You asked:

What is the JDK to Java SE equivalence?

Every generation of Java specifications use the same numbering as their implementations found in various JDK/JRE products.

So Java 24 specs are implemented by JDK/JRE products numbered 24. Java 25 specs are implemented by JDK/JRE products numbered 25. Sensible and orderly.

More info

For more details, see the whitepaper Java Is Still Free written by pillars of the Java community.

like image 141
Basil Bourque Avatar answered Oct 30 '25 16:10

Basil Bourque