How to run and debug the Preview function in Java's new features

The features released in each new version of Java will include some Preview functions, which are mainly used for developers to experience and collect suggestions. Therefore, the functions in the Preview stage are not enabled by default.

If you want to experience the Preview function in a certain Java version, you still need to make some settings to run the program.

The following takes IDEA 2023.2 as an example to demonstrate enabling the Preview function for Java 21.

Step 1: Open settingthe configuration compilation parameters, as shown in the figure below: select the Java version and add the configuration parameters to enable preview--enable-preview

Step 2: Configure Run/Debugparameters and add them to VM parameters--enable-preview

When you execute the relevant test code again, you can see that the parameters have been included --enable-previewand the preview function is running normally.

Welcome to pay attention, I am serializing the new Java features column

Welcome to follow my public account: Programmer DD. If we had known about cutting-edge technology, there would be hope for overtaking on curves! To accumulate overtaking capital, start by paying attention to DD!

Guess you like

Origin blog.csdn.net/dyc87112/article/details/133544264