Programming

Java 17

What is Java 17?

Java 17 came out in September 2021 and is an LTS release. The wide LTS before it was Java 11, and Java 21 came later. In 17, records, sealed classes, and pattern matching for instanceof are finished. Text blocks arrived earlier and are in 17 too.

What is Java 17 used for?

Java 17 is a target for a server app, a library, and some Android build tools.

  • A server framework such as Spring
  • Moving old Java 8 or 11 code
  • A short data type with a record
  • Keeping the JDK tools stable

What can you do with Java 17?

With Java 17 you can move a program written on Java 11 to newer syntax after you test it. In a new project a record shortens a DTO. The very newest syntax, including some things from a later LTS, is not in 17.

Is Java 17 hard to learn?

For someone who knows Java, 17 is not a new language. The difficulty is the move from an old JDK, removed internal APIs, and the version of the build tool. If java --version does not show 17, the code is not on 17.

Advantages and limits

Advantage: years of support, stability, and a wide library set. Limit: some language features from 21 and later LTS releases are not here. If a project is still on 8, the move is not free of tests.

Basic ideas

The JDK gives the language and the tools. A JRE is only for running. A record is a short class with fields.

  • LTS means long-term support
  • A sealed class limits who can extend it
  • Pattern matching shortens an instanceof check
  • Gradle or Maven chooses which JDK builds the project

A short example

First look at the installed version. Then a record writes a small data type like this.

java --version

record Point(int x, int y) {}

Common questions

  • Is Java 17 the newest version? No. A newer LTS exists. 17 is still the target in many places.
  • Are Java 17 and the Java language different? No. 17 is one release of the language.
  • Is Java 17 enough for Android? Yes if the build tool allows it. The project's Gradle file shows that.