[Java] Java version control with SDKMAN

2 minute read


It seems that Oracle Java has become commercialized for commercial use, and it was troublesome to install it with the GUI, so I thought that I would like to be able to manage Java version with CLI like nodenv of JavaScript somehow.

Is there a Java version control tool like xxxenv?

There was something called jenv. However, it seems that Java itself needs to be installed by itself, and jenv seems to be positioned as a version switching tool.

I like being able to install and switch versions like nodenv.


I found SDKMAN when I searched for something that can be installed and switched versions. I installed it referring to the following. #Java: vol1: [java/JDK version management best practices]

By the way, I tried to install Java 8 of AdoptOpenJDK this time, but there are two in list.

% sdk list java
  • 8.0.252.j9-adpt
  • 8.0.252.hs-adpt

It seems that the JVM is different when I look it up. Download and install AdoptOpenJDK

j9 = OpenJ9

Eclipse OpenJ9 is a JVM from the Eclipse community. An enterprise-class JVM designed for low memory usage and fast startup, used in IBM’s JDK.

hs = HotSpot

HotSpot is a JVM from the OpenJDK community. It is currently the most widely used JVM and is used by Oracle’s JDK.

It seems to mean that, so this time I safely tried to use the same hs as the conventional Oracle. (I think OpenJ9 is for enterprises and has high functionality. Should I use this in the future?)

Uninstall Oracle Java

I think I could refer to this. .. .. (faint memory) How to uninstall Java on Mac

After uninstalling Oracle Java, the example dialog is displayed!

To use the ““java” command line tool every time you start IntelliJ IDEA, you need to have the JDK installed. A dialog like has been displayed by sdkman` even after Java installation.

As a workaround, File >Invalidate Caches / Restart no longer displays the dialog. JDKs installed with SDKMAN are not selectable in the IntelliJ IDE


% java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode)

Also, I was able to run a traditional Java project in IntelliJ IDEA. It seems to be okay for the time being.

Future tasks

If you think that you have migrated your Android development environment as well, it seems that Android Studio includes a JDK. What is this guy really? I would like to think about Android when it is needed again.

/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/java -version
openjdk version "1.8.0_242-release"
OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
OpenJDK 64-Bit Server VM (build 25.242-b3-6222593, mixed mode)