Skip to content
Tutorials Center
My learning

Topics

Lesson 166 of 201 ยท JVM and Advanced Topics

Java Versions and History

A guided tour of Java's history from 1.0 to Java 25 - LTS releases, the six-month cadence, headline features of each version, preview features and Runtime.version().

Java has been around since 1996, and the language you've learned in this course looks very different from the Java of the early days. Records, var, switch expressions, text blocks, virtual threads and compact source files are all recent additions. When you read older code, a tutorial from 2012 or a Stack Overflow answer, you'll meet older styles, and when you join a company you'll hear questions like "are we on 17 or 21 yet?"

This lesson gives you the map: how Java's release model works, what Long-Term Support (LTS) means, the headline features of each important version, how preview features let you try what's coming, and how a program can find out which Java it's running on. You don't need to memorize version numbers; you need to recognize when a feature arrived, so you know which code will compile on the Java version a project uses.

Where Java came from

Java started in 1991 at Sun Microsystems, where a team led by James Gosling designed a language for consumer devices. It was first called Oak, renamed Java in 1995, and Java 1.0 was released in January 1996 with a famous promise: write once, run anywhere. Code compiled to bytecode runs on any machine with a Java Virtual Machine (How Java Works).

Three events shaped the ecosystem you work in today:

  • OpenJDK (2006โ€“2007). Sun released Java's source code as open source. Today almost every JDK, whether from Oracle, Eclipse Temurin, Amazon Corretto, Microsoft, Azul or Red Hat, is built from the OpenJDK project.
  • Oracle (2010). Oracle bought Sun and became Java's steward; the language still evolves in the open through JEPs (JDK Enhancement Proposals), each a numbered design document such as "JEP 444: Virtual Threads".
  • Jakarta EE (2017 onward). The enterprise APIs (servlets, JPA and friends) moved to the Eclipse Foundation and were renamed from javax.* to jakarta.* packages. That's why older enterprise code imports javax.servlet and newer code jakarta.servlet (Jakarta EE Overview).

The release model: every six months, LTS every two years

Until Java 9, releases came whenever a big feature was ready, sometimes years apart. Since Java 10 (March 2018) a new feature release ships every six months, in March and September, like clockwork. Whatever is finished goes in; whatever isn't waits for the next train.

Most releases are supported only until the next one arrives, six months later. Some are designated Long-Term Support (LTS) releases, which vendors maintain with security and bug fixes for many years. Companies run production systems on LTS versions and upgrade from one LTS to the next:

LTS version Released Why it matters
Java 8 March 2014 lambdas and streams; still found in older systems
Java 11 September 2018 first LTS of the six-month era
Java 17 September 2021 records, sealed classes, text blocks; a common baseline (Spring Boot 3 requires it)
Java 21 September 2023 virtual threads, pattern matching for switch
Java 25 September 2025 compact source files; the version this site runs

Since Java 17, an LTS comes every two years (every fourth release), so the next one is planned for Java 29 in September 2027. Java 26 (March 2026) and Java 27 (September 2026) arrived on schedule. Because the dates are so regular, you can compute them:

Java Computing Java release dates

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

The formula reproduces the real calendar: Java 21 in 2023-09, Java 25 in 2025-09. The LTS rule is a convention vendors follow, not a law of nature, but it has held since Java 17.

Which Java am I running?

The version string changed with Java 9. Before that, versions were written 1.x: Java 8 reports itself as 1.8.0_441, Java 7 as 1.7.0_80. Since Java 9 the format is FEATURE.INTERIM.UPDATE.PATCH, such as 21.0.6 or 25.0.4. Runtime.version() parses it for you, which is how libraries decide whether a newer API is available:

Java Runtime.version() and system properties

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

The java.class.version property is the class-file version: Java 25 writes version 69 bytecode, Java 21 writes 65, Java 17 writes 61, Java 8 writes 52 (the feature number plus 44). A JVM refuses to load class files newer than itself, with an UnsupportedClassVersionError saying something like "class file version 69.0, this version of the Java Runtime only recognizes class file versions up to 65.0". That error means "compiled with a newer JDK than the one running it". Compile with javac --release 21 (or maven.compiler.release in a build tool) to target an older Java.

The headline features, version by version

This table lists what each release is remembered for. "Final" features are permanent parts of Java; many were previewed in earlier releases first.

Version Year Headline features
1.0 1996 the first release: applets, AWT, the core language
1.1 1997 inner classes, JDBC, reflection, serialization, RMI
1.2 1998 the Collections Framework, Swing, a JIT compiler; branded "Java 2"
1.3 2000 the HotSpot JVM becomes the default
1.4 2002 assert, regular expressions, NIO, java.util.logging, chained exceptions
5 2004 generics, enums, autoboxing, for-each, varargs, annotations, static import, java.util.concurrent, Scanner, StringBuilder, printf
6 2006 the Compiler API (javax.tools), scripting API, JDBC 4, performance work
7 2011 try-with-resources, diamond <>, strings in switch, multi-catch, binary literals and _ in numbers, NIO.2 (Path, Files), Fork/Join, Objects
8 (LTS) 2014 lambdas, method references, streams, default methods, java.time, Optional, CompletableFuture
9 2017 the module system (JPMS), JShell, List.of/Set.of/Map.of, private interface methods, G1 as default GC, compact strings
10 2018 var for local variables, List.copyOf
11 (LTS) 2018 the HTTP Client, running a .java file directly, new String methods (isBlank, strip, lines, repeat), Files.readString; Java EE and CORBA modules removed
12โ€“13 2019 previews of switch expressions and text blocks; Collectors.teeing, String.indent
14 2020 switch expressions final, helpful NullPointerException messages
15 2020 text blocks final, ZGC and Shenandoah production-ready, Nashorn JavaScript engine removed
16 2021 records and pattern matching for instanceof final, Stream.toList(), jpackage
17 (LTS) 2021 sealed classes final, RandomGenerator, HexFormat, strong encapsulation of JDK internals
18 2022 UTF-8 as the default charset, a simple web server (jwebserver), @snippet in Javadoc
19โ€“20 2022โ€“23 previews of virtual threads, record patterns and structured concurrency
21 (LTS) 2023 virtual threads, record patterns, pattern matching for switch, sequenced collections, generational ZGC
22 2024 unnamed variables and patterns (_), the Foreign Function & Memory API, launching multi-file source programs
23 2024 Markdown documentation comments (///), generational ZGC by default
24 2025 stream gatherers, the Class-File API, virtual threads no longer pinned by synchronized, ahead-of-time class loading
25 (LTS) 2025 compact source files and instance main methods, module import declarations, flexible constructor bodies, scoped values, compact object headers

Three releases changed how everyday Java looks: Java 5 (generics and enums), Java 8 (functional programming with lambdas and streams) and the run from Java 14 to 21 (records, sealed types and pattern matching, often summarized as "data-oriented programming"). Java 25 then made the language friendlier for beginners: the void main() { IO.println("Hi"); } program from the first lesson is a Java 25 feature.

The same program, then and now

Here is one small task, "group orders by customer and print each customer's total", written the way you would have to write it in Java 7, then in Java 25. Both run on Java 25, because Java is backward compatible: old code keeps compiling.

Java Java 7 style vs Java 25 style

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

The modern version isn't just shorter: the record gives Order correct equals, hashCode and toString for free, and groupingBy states the intent ("total per customer") instead of spelling out the map bookkeeping.

A tour of modern features in one program

This program uses one headline feature from each recent era. Each comment names the version that made the feature final; the program compiles only on Java 25 or newer, because of its compact-source form.

Java Modern Java features by version

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

If you ever need to run code on an older Java, this list tells you what to remove: on Java 17, for instance, you'd need a class with static void main, System.out.println instead of IO, and an if/instanceof chain instead of the pattern-matching switch.

Preview, incubator and experimental features

Big language changes don't arrive in one step. They usually appear first as preview features: complete, but not yet permanent, so developers can try them and give feedback. Records, for example, were previewed in Java 14 and 15 and became final in 16. Compact source files were previewed four times (Java 21 to 24) before becoming final in Java 25.

Preview features are disabled unless you opt in, at compile time and at run time:

Terminal
javac --release 25 --enable-preview Main.java
java --enable-preview Main

# Running a source file directly
java --enable-preview Main.java

In Java 25, previews include structured concurrency, primitive types in patterns and stable values (Virtual Threads and Structured Concurrency). There are also incubator modules (APIs that may still change a lot, like the Vector API in jdk.incubator.vector) and experimental JVM features enabled with -XX:+UnlockExperimentalVMOptions.

Preview features can change or disappear. String templates were previewed in Java 21 and 22 and then removed in Java 23 for a redesign. Never ship production code that depends on a preview feature; class files compiled with --enable-preview only run on that exact Java version.

Upgrading between versions

Java is strongly backward compatible, so most code runs unchanged on newer versions. The real upgrade work usually comes from a few kinds of changes:

  • Removed APIs and modules. Java 11 removed the Java EE modules (javax.xml.bind for JAXB, javax.activation), which are now ordinary dependencies; Java 15 removed the Nashorn JavaScript engine; the Security Manager was permanently disabled in Java 24.
  • Strong encapsulation. Since Java 16โ€“17, code (often old libraries) that used reflection on JDK internals fails with InaccessibleObjectException unless it's updated or given --add-opens (Modules).
  • Dependencies and tools. Your build tool plugins, bytecode libraries and frameworks must support the new class-file version. Upgrade them first.
  • Behavior details. For example, the default charset became UTF-8 in Java 18 (Character Sets and Encoding).

A practical path: upgrade the build to the new JDK, fix warnings and deprecations (compile with -Xlint:deprecation), run the full test suite (Unit Testing with JUnit), and only then start using new language features.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which of these releases are Long-Term Support (LTS) versions?

    Java 8, 11, 17, 21 and 25 are LTS releases. Since Java 17, an LTS comes every two years (every fourth six-month release).
  2. 2. A program fails with UnsupportedClassVersionError: class file version 69.0, this runtime only recognizes up to 65.0. What happened?

    Class-file version 69 corresponds to Java 25 and 65 to Java 21. Run it on a newer JVM, or compile with --release 21 to target the older version.
  3. 3. In which version did records become a final (non-preview) feature?

    Records were previewed in Java 14 and 15 and became final in Java 16, together with pattern matching for instanceof.
  4. 4. Running on Java 25.0.4, what does Runtime.version().feature() return?

    The version format is FEATURE.INTERIM.UPDATE.PATCH, and feature() returns the first number as an int. update() would return 4.
  5. 5. Why shouldn't production code rely on preview features?

    Preview features are complete but not permanent. String templates, for example, were previewed and then removed, and preview-enabled class files are tied to one release.

Summary

  • Java was created at Sun by James Gosling's team (1.0 in 1996); today it's developed in the open as OpenJDK, with changes proposed as JEPs, and many vendors ship free builds.
  • Since Java 10, feature releases arrive every March and September; LTS releases (8, 11, 17, 21, 25) get years of fixes, and companies upgrade from LTS to LTS.
  • Landmark versions: 5 (generics, enums), 8 (lambdas, streams, java.time), 9 (modules), 10 (var), 11 (HTTP Client), 14โ€“17 (switch expressions, text blocks, records, sealed classes), 21 (virtual threads, pattern matching), 25 (compact source files).
  • Runtime.version() returns the running version (feature(), update(), ...); class-file versions are the feature number plus 44, and newer class files fail on older JVMs with UnsupportedClassVersionError.
  • Preview features need --enable-preview, may change or vanish, and don't belong in production code.
  • Upgrades are mostly about removed APIs, strong encapsulation and dependency support; upgrade the build and tests first, then adopt new features.

Next: Project: Number Guessing Game.