QimTech

Java 17: what’s new

Everything you always wanted to know about Java 17: improvements, new features, downloads, training.

Java 17 is a major release of the Java programming language, designed to offer improved performance, stability, and security in production environments. In summary:

  • Java 17 is an LTS release with long-term support.
  • It introduces key new features to the language (records, sealed classes, and a new switch statement).
  • It is suitable for cloud and containerized environments.
Overview

Java 17 overview

The Java Programming Language

Java is an essential programming language for software development, as many advancements rely on its use: used on computers, smartphones, and even game consoles, it has become indispensable.

Up to Java 8, the major versions Java releases were published several years apart. Since Java 9 (2017), Java has followed a six-month release cycle.

💡You might be interested in our articles on the most commonly used programming languages for software development or on custom software development.


What about Java 21? Java 17 remains one of the most widely used versions in the enterprise thanks to its LTS status and support through 2029, even though Java 21 is now the recommended LTS version for new projects.

Key Features of Java 17

This is a major version, which reflects Oracle’s ongoing efforts to improve and modernize its flagship programming language. Oracle has built upon previous versions of Java to further develop them, while also taking into account current trends in programming.

As such, Java 17 is the result of numerous performance improvements, new language features, bug fixes, and security enhancements. In line with Oracle’s release strategy, as an LTS version, Java 17 benefits from a long-term support, which means it will receive security and bug fixes until 2029.

This is a significant advantage, making this version particularly suitable for use in production environments.

Why use Java 17?

Here are some of the most notable benefits of Java 17:

  • The native support for macOS/AArch64 via JEP 391, enabling Java to run on Apple Silicon processors (M1 and later) without relying on Rosetta 2 emulation.
  • Starting with Java 17, Oracle distributes its JDK under the Oracle No-Fee Terms and Conditions (NFTC) license, which, among other things, allows for free use—including in production—during the support period provided by Oracle.
  • A widely used language : According to New Relic’s “State of the Java Ecosystem” published in 2022, Java 17 has surpassed Java 6, Java 10, and Java 16 in the few months since its release.
  • Java 17 is part of a trend toward widespread adoption of cloud architectures and containerized, to which the JVM has gradually adapted by better accounting for the resources allocated to containers.
  • A shorter interval between Long-Term Support (LTS) releases : Since enterprise applications rely heavily on Java, stability is essential. LTS versions were created to provide users with extended support. As a result, these versions naturally become more stable and secure. Starting with Java 17, the interval between LTS releases is now two years instead of three.

Java 17 improvements over previous versions

Sealed classes and interfaces

We are all familiar with thelegacy, a cornerstone of object-oriented programming.

With sealed classes, it is now possible to precisely define the scope of a class by specifying which classes are allowed to inherit from it. This also works with interfaces and their implementations.

Implementing this new feature involves adding two keywords: sealed and permits. Let’s look at an example to illustrate this.

Here I’ve defined a sealed interface called Service (note the presence of thesealed keyword ). Only the Car and Truck classes can implement this interface, thanks to the permits keyword .

Text blocks

It’s finally possible to create text blocks easily! This new syntax is very useful for writing XML or JSON, for example.

Note that spaces are preserved, so the indentation of the text block will be maintained.

Type Record

A record makes it easy to create immutable objects. Here’s an example using a class Personclass, which contains data related to a person (name, age, etc.).

Here is the syntax that was used in most cases prior to Java 17 to define this class:

And here is the new Java 17 syntax.

As you can see, the record attributes are defined in a much more readable way and require less tedious code.

There is, however, one notable constraint with this new type: since the class is final, it cannot inherit from other classes.

Pattern matching

This feature concerns the keyword instanceof keyword, which is used to check the type of an object.

It is no longer necessary to create an object by casting. With the new syntax, the object is created when instanceof is called, and its properties can be called directly afterwards, without having to use a temporary object.

New Switch

The new switch syntax allows for a drastic reduction in the number of lines of code.

It is now possible to return a value using a switch statement.

In addition, the new switch allows you to use the new pattern-matching syntax introduced in the previous paragraph and to create conditions within clauses.

How to download Java 17

Check that no previous versions are installed on your OS

To do this, launch the command prompt and write “java – version”. If no previous version is installed, you will see the following message: “‘java’ is not recognized as an internal or external command, executable program or command file”.

If not, you must uninstall the previous version.

Download the kit for your OS

To do this, access the archive versions on Oracle and select 17. As Oracle reminds us, older versions of the JDK (development environment) are provided to help developers debug problems on older systems. They are not updated with the latest security patches and are therefore not recommended for production use.

How do I learn Java 17?

We suggest 2 methods, which are valid for every version of Java.

For the self-taught: books, tutorials, articles...

Of course, we advise you to choose relatively recent documents, which take into account the latest technological developments.

The Internet is full of valuable information to help you make sense of it all.

For example, we can recommend certain YouTube videos, such as the channel Graven Développement .

Similarly, the MOOC created by the Ecole Polytechnique de Lausanne can provide you with an effective foundation in coding with Java.

For experienced developers: certifications

Certifications have two key benefits: the first is to encourage you to become an expert in your field, and the second is to offer recognition of your skills and knowledge. Among the existing certifications, we will present two.

  • Java Foundations 1Z0-81 certification This is the first certification a new Java developer should obtain. This is a fundamental level exam, demonstrating your understanding of the Java language and programming concepts. It validates your skills in writing and executing a Java program, working with the Java Development Kit (JDK) and the Java Runtime Environment (JRE).
  • Java SE 17 certification (1Z0-829) This 90-minute exam certifies you as an Oracle Professional Developer for Java 17.

You now have all the keys you need to tackle Java 17 with peace of mind! We hope you have found this article useful. We invite you to consult the articles in our Qim Tech which can provide further insight on other topics, as well as our article on Java developers. Perhaps our guide to Angular and React will also be helpful to you.

FAQ

When is Java 17 scheduled to be released?

September 2021.

If we had to single out one major difference, it would be that Java 17 introduces significant language enhancements that make the code more expressive, safer, and easier to maintain, whereas Java 11 was primarily a consolidation release following the structural changes introduced by Java 9.

Yes, it’s actually one of the most common versions used in businesses, for several reasons:

  • Java 17 is a LTS (Long-Term Support) release.
  • Oracle will provide support through September 2029 (extended support), and many OpenJDK distributors also support it for several years.
  • Many companies prioritize stability and do not upgrade with every new semi-annual release.
Contents