Preview the new features in Java

Every version of Java contains some features that are only in 'Preview' status and are not supported for production.

The goal of these features is to allow developers to test and comment potential future functions before they are officialy released.

To enable the new feature you need to use some flags:

Standard compilation

javac --enable-preview --release [release number] [your main class name].java

java --enable-preview [your main class]


javac --enable-preview --release 14  
java  --enable-preview HelloWorld 


If you are using JShell it's enough to launch the shell with the --enable-preview flag;

> jshell --enable-preview

Single-source-code program

java --enable-preview [your java source code class]

java --enable-preview HelloWorld

WebApp built by Marco using SpringBoot, Java 16, Mustache, Markdown and Hosted using Jelastic