Java Versions and Release Cycle

Naveen AnamaneniUpdated · 7 min read

Suppose your college lab has Java 8, a job description asks for Java 17, and a tutorial uses a feature from Java 21. Will your code work everywhere? It depends on the version, so you need to know how Java versions work.

Choosing the version also matters at work. A bank won't run its payment system on a version that stops getting security fixes in six months. That's why it picks an LTS version and upgrades from one LTS to the next.

Version Numbers

Older Java versions had confusing names. Java 5 was internally "1.5", and Java 8 still reports its version as 1.8.0_ followed by an update number. Since Java 9, version numbers are simple: 9, 10, 11 and so on, up to 25 and beyond.

A full version such as 25.0.2 means:

PartMeaning
25The feature release: the main version number
0The interim release (almost always 0)
2The update number: bug and security fixes, no new language features

A New Release Every Six Months

Before 2018, there were often three or more years between versions: Java 7 came out in 2011, Java 8 in 2014 and Java 9 in 2017. Developers waited a long time for new features.

Starting with Java 10 in March 2018, Java moved to a fixed schedule: one feature release every March and every September. Each release is smaller, but you get improvements much sooner, and companies can plan their upgrades.

Two releases a year; an LTS release every two years

LTS and Feature Releases

LTS releaseFeature release
Examples8, 11, 17, 21, 2522, 23, 24, 26, 27
How oftenEvery two years (since Java 17)Every six months
Updates and security fixesFor many years, from several vendorsOnly until the next release
Who uses itCompanies, in productionDevelopers who want the newest features

Java 11 (2018) and Java 17 (2021) came three years apart. Since Java 17, an LTS version arrives every two years: Java 21 in September 2023 and Java 25 in September 2025. If the schedule continues, the next LTS will be Java 29 in September 2027. At the time of writing (November 2026), the newest release is Java 27, a feature release.

What Each LTS Version Added

LTS versionReleasedHeadline features
Java 8March 2014Lambdas, the Stream API, a new date and time API
Java 11September 2018HttpClient, running a single .java file directly
Java 17September 2021Sealed classes; also includes records and text blocks from Java 15–16
Java 21September 2023Virtual threads, pattern matching for switch, record patterns
Java 25September 2025Compact source files, scoped values, flexible constructor bodies

Don't worry about these feature names now. Each one has its own lesson later in the course, and a summary lesson near the end brings them all together.

Preview Features

Sometimes a new feature appears as a preview first. It works, but it may still change, so you have to switch it on with the --enable-preview option. After feedback from developers, it becomes final in a later version. Pattern matching for switch, for example, was a preview in Java 17 to 20 and became final in Java 21.

Check the Version in Code

A program can check which Java version it is running on. This example tells you whether virtual threads (a Java 21 feature) are available.

VersionCheck.java▶ Try it
public class VersionCheck {
    public static void main(String[] args) {
        int version = Runtime.version().feature();
        System.out.println("Java version: " + version);
 
        if (version >= 21) {
            System.out.println("Virtual threads are available.");
        } else {
            System.out.println("Use Java 21 or newer for virtual threads.");
        }
    }
}
Output
Java version: 25
Virtual threads are available.

How it works

  1. Line 3 reads the feature release number, such as 25, and stores it in version.
  2. Line 4 prints it.
  3. Line 6 compares it with 21. If the version is 21 or higher, the first message prints; otherwise the second one does. You'll learn if and else in "Java If-Else Statements".

The output above comes from Java 25. On another version, the first line shows that version.

Try it yourself: change 21 on line 6 to 30. Which message prints now, and why?

Common Mistakes

Learning Java 8 because it is "the one companies use". Many companies still run Java 8, but most new projects start on 17, 21 or 25. If you learn Java 25, you can still read Java 8 code, but a Java 8 course won't teach you records, var or virtual threads.

Using a feature release in production. A feature release such as Java 24 stopped getting updates when Java 25 came out. For anything that runs for a long time, choose an LTS version.

Mixing up compile and run versions. Code compiled with a newer Java may not run on an older JVM. If you compile with Java 25 and the server has Java 17, you'll see an UnsupportedClassVersionError.

Interview Corner

What is an LTS release in Java?

A long-term support release gets bug and security fixes for several years, so companies can use it safely in production. The LTS versions are Java 8, 11, 17, 21 and 25.

How often is Java released?

A new feature release comes every six months, in March and September, since Java 10 in March 2018. An LTS release comes every two years since Java 17.

Which Java version would you use for a new project, and why?

The latest LTS version, Java 25, because it has the newest features and will receive security updates for years. If a framework or company policy requires it, the previous LTS, Java 21, is also a safe choice.

Practice

  1. Easy: Write down which of these are LTS versions: 11, 14, 17, 20, 21, 24, 25.
  2. Harder: Search for the Java version required by a framework you've heard of, such as Spring Boot. Is it an LTS version?

Quick check: Java versions

4 questions
1How often is a new Java feature release published?
2Which of these is an LTS version?
3In version 25.0.2, what does the 2 mean?
4Which version should a bank choose for a new payment system?

Key Takeaways

Was this tutorial helpful?

Lesson 4 of 482