6

Java test preview features

 3 years ago
source link: https://marco.dev/java-test-preview-features
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

To know what’s included in this the latest Java release: http://java-version.com/java

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)

intellij-preview.gif

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK