'Run loom demo on IDEA
I want to run loom's demo, I downloaded jdk18-loom from http://jdk.java.net/loom/, and downloaded the latest version of IDEA
:
No matter I choose X
or 17-preview
, the program cannot run, reports:
Executors.newVirtualThreadPerTaskExecutor() Is an API in a preview feature
.
How to solve it?
Solution 1:[1]
What I had to do step by step.
Update to the IDE to the latest version
Download a jvm with loom
Add the loom JDK to the IDE
Set it both to project and to your build tool
Set enable preview and source to 19 as compiler options to do this, got to prefs -> compiler -> java compiler, uncheck the --release option thing and add the following compiler args for specific project global
--enable-preview --source 19
these are directly passed to javac when it compiles
Set the enable preview on you run configuration
add --enable-preview
as a jvm option (if you don't see it click 'Modify options')
You should be good to go, I faced a bug where sometimes gradle complained that it is not compatible with my JVM, to resovle this I had to switch the gradle VM to java 17, wati for it to build and them back to 19
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Borislav Stoilov |