I was able to play around with the latest early access binary for Project Loom by downloading the file from http://jdk.java.net/loom/, extracting it (I had a directory called jdk-18
), setting the JAVA_HOME
env var to the jdk-18
directory, and adding the bin
subdirectory for the build to the beginning of my PATH
env var. I was able to use the build to compile and run a Java program using the virtual thread preview features.
But this feels like a very manual process. I like how SDKMAN manages JDKs on my system. How can I set up this early access build (or any other JDK build for that matter) as an entry in the list of JDKs managed by SDKMAN, so that I could change to it, for example, by typing sdk default java <my-jdk-18-name>
?
SDKMAN has a feature called "Install Local Version(s)" (https://sdkman.io/usage#localversion).
So, to set up a custom build of the JDK with SDKMAN, I can download and install the JDK wherever I want and then link it to SDKMAN so that it's useable like any other JDK managed by SDKMAN:
wget https://download.java.net/java/early_access/loom/7/openjdk-18-loom+7-288_linux-x64_bin.tar.gz
tar -xf openjdk-18-loom+7-288_linux-x64_bin.tar.gz
mv jdk-18/ 18-loom
sdk install java 18-loom $(realpath 18-loom/)
After installing and linking:
~/javas > sdk default java 18-loom
Default java version set to 18-loom
~/javas > which java
/home/matt/.sdkman/candidates/java/current/bin/java
~/javas > java --version
openjdk 18-loom 2022-03-15
OpenJDK Runtime Environment (build 18-loom+7-288)
OpenJDK 64-Bit Server VM (build 18-loom+7-288, mixed mode, sharing)