Enable Preview Feature in Idea With Gradle 7.6
When I am trying to use the Java virtual thread in Idea with Gradle 7.6, I got error,
Bash
/java-examples/src/main/java/com.veda/app/virtualthread/VirtualTheadExample.java:5: error: ofVirtual() is a preview API and is disabled by default.
System.out.println(Thread.ofVirtual().factory());
^
(use --enable-preview to enable preview APIs)
We need some configurations to enable the preview feature for Idea with Gradle 7.6.
-
Right click the project and open module setting
Then in the project ->
Language Level
, enable the language preview feature. -
In the
build.gradle
file, add the following content
Now, it should be ok now.