Java test preview features

Updated:

In 2 minutes

Every new Java release contains few new features in preview. This allows the community to test / review / comment them.

These features are not 'production ready' and they could disappear or change in the following releases.

Here you can find a nice explanation from Oracle: The role of preview features in Java 14, Java 15, Java 16, and beyond

How to use the preview features

JShell

JShell should contain all the new preview features without lag.

To test them you can simply add --enable-preview to the jshell command.

Here a quick tutorial:

Command line

To run code that includes preview features you should compile your source using the flags javac --enable-preview --release [release nr.] [source].java
and execute it using java --enable-preview [mainclass].

IntelliJ

In IntelliJ you can configure the JDK used for the project:

Project Structure ...

Be sure that Project language level is set on [version] (Preview)

You cannot use the preview features in the JShell Console ... included in IntelliJ. This console is very limited.


WebApp built by Marco using SpringBoot 3.2.4 and Java 21, in a Server in Switzerland