Fundamentals 3 min read

Enable Java 21 Preview Features in IntelliJ IDEA 2023.2

This guide explains how to enable Java 21 preview features in IntelliJ IDEA 2023.2 by configuring compiler and runtime options, allowing developers to experiment with upcoming language capabilities such as unnamed classes, patterns, and virtual threads.

Programmer DD
Programmer DD
Programmer DD
Enable Java 21 Preview Features in IntelliJ IDEA 2023.2

Each new Java release includes Preview features that are not enabled by default, allowing developers to try them and provide feedback.

To use a Preview feature in a specific Java version, you must configure your IDE and runtime accordingly.

Below is a step‑by‑step guide for enabling Preview features of Java 21 in IntelliJ IDEA 2023.2.

Step 1: Configure compiler settings

Open Settings, select the desired Java version, and add the compiler option --enable-preview as shown in the screenshot.

Step 2: Configure Run/Debug VM options

In the Run/Debug configuration, add the VM option --enable-preview.

When you run your test code, the --enable-preview flag will be present, and the Preview feature will work correctly.

Recommended Reading

Java 21 New Feature: Unnamed Classes and Instance Main Methods – http://mp.weixin.qq.com/s?__biz=MzAxODcyNjEzNQ==∣=2247579672&idx=1&sn=01012855143d177725d027dcc0d85eed

Java 21 New Feature: Unnamed Patterns and Variables – http://mp.weixin.qq.com/s?__biz=MzAxODcyNjEzNQ==∣=2247579672&idx=2&sn=f718dbe72feafb5e64d296d67be0c78b

Java 21 New Feature: Virtual Threads – http://mp.weixin.qq.com/s?__biz=MzAxODcyNjEzNQ==∣=2247579656&idx=1&sn=48fcc1d0d53a78f0ec4aec4103aa1163

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

javaConfigurationIDEAJava 21preview features
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.