Unfortunately, even the latest early-access versions of IntelliJ often do not yet support early-access versions of Java.
For example, I am trying to use Intellij 2022.1.1 Preview (Ultimate Edition) with the experimental build of Project Loom based on early-access Java 19. Installing JDK generally works with IntelliJ.
But now I want to use the Loom-specific features. When I invoke a method new in to this experimental Java 19, I get this error from compiler:
java: newVirtualThreadPerTaskExecutor() is a preview API and is disabled by default.
(use --enable-preview to enable preview APIs)
My first thought is to set the Language level fields on the File > Project Structure > Project Settings > Project and … Modules panels. But apparently IntelliJ does not offer any menu items for a (Preview) mode for this early-access Java 19.
Is there some way to make IntelliJ utilize the new preview API?
I know the error message's suggestion of --enable-preview
is meant to be a flag applied somewhere. But I don't know where.
Gradle based Java Compiler Argument, In Intellij IDE
Follow these 2 steps:
In gradle based Java projects we can enable Java features by modifying the "build.gradle" file like below. I'm currently using Java 21.