Managing multiple jdk versions using sdkman
It is a common use-case to have multiple versions of various tools installed on your computer. Notable examples are different JDK versions or gradle. For a long time I installed them manually and added aliases to my shell configuration like that:
This works well for tools like gradle, but installing and maintaining multiple JDK versions was always a bit of a pain. Recently I found a very neat and amazing solution to this problem: sdkman.
It is a small tool that manages multiple versions of development kits on your computer. Installation is very easy:
and afterwards add something like this to your .bashrc or respective profile script:
Now you should be able to use the sdk command to install different SDKs or change the current version in use:
will print something like this:
You can see that I have installed different JDK versions and version 8.0.242.hs-adpt is currently the default.
To switch to another version by default you can use for example sdk use java 11.0.6.hs-adpt
.
Its an amazing tool and I can recommand it for anyone using a unix-based workstation.
Note: in case you are wondering about the suffixes: hs and j9. They refer to the actual JVM in use:
- good old Hotspot
- OpenJ9
The suffix fx indicates whether the JDK comes pre-packages with the JavaFX / OpenJFX toolkit (which is not part of the Oracle / OpenJDK distributions anymore).
Comments
No comments found for this article.
Join the discussion for this article on this ticket. Comments appear on this page instantly.