SDKMAN! for Java

I always install Node.js through nvm and Python through pyenv. Node.js keeps project dependencies inside the project folders itself and doesn’t clutter the system. Similarly, for Python, there is venv which helps me keep dependencies isolated. But I was not using any such thing for Java development. I always had the latest LTS release of JDK installed globally and used it for everything. This used to work always because Java versions didn’t have to be changed as often as Node.js or Python (between Python 2 and 3). In fact, Java version didn’t have to be changed at all.

But now I have a need to switch between Java 8 and Java 11 as part of my work. And also, I’d like to keep up with new features in new releases of Java. Also, I need to test my software with a couple of JVMs ever since Oracle messed with their support terms for Java sometime in the last year. So in summary, I need to now frequently switch versions / distributions of JDK on my computer. Yeah, there is the alternatives thing for Linux, but I found a neater, open-source solution on the internet. SDKMAN!

SDKMAN! is a pyenv alternative or nvm alternative for Java. Read their install and usage documentation for detailed instructions and their full feature set. Some commands –

  • sdk install java to install the latest stable OpenJDK
  • sdk list java to list all available Java installations (with info on what’s already installed)
  • sdk install java 16.0.2.7.1-amzn to install Amazon Corretto JDK version 16
  • sdk use java 11.0.11.hs-adpt to switch to OpenJDK 11 for the current shell
  • sdk default java 16.0.2.7.1-amzn to switch to Amazon Corretto JDK as the default

There is many more features, support for other tools like Ant, Spring Boot and so on. There’s even a .sdkmanrc file that can be added in my project so everyone in my team can stay on the same version. This is a neat little tool that I wish I had found earlier.

Author: heppydepe

I'm Heppy Depe. (Read "Heppy" like "Peppy" and "Depe" like "DayPay"). Writing under a pseudonym because .. I dunno I just felt like writing under a pseudonym. I'm still trying to find the perfect picture of a fish to set as my profile photo.

One thought on “SDKMAN! for Java”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: