byandrev's blog

2 min read

SDKMAN - Java version management

What is SDKMAN?

SDKMAN is a version manager for Unix-based environments (Linux and macOS), and it can also be used on Windows with WSL. It allows you to easily install and switch between different versions of Java and other related tools in this ecosystem. It’s simple to use since it operates from the terminal, similar to how nvm works for Node.js users.

Installation

To install SDKMAN, you need to have the zip package installed to ensure the command works correctly.

bash
curl -s "https://get.sdkman.io" | bash

After installation, reload some configuration data:

bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

How to Install a Java Version

To install a specific version of Java, run the following command:

bash
sdk list java

This will display a list of all available Java versions. Copy the Identifier of the version you want to install and then run:

List of available Java versions to install with SDKMAN
List of available Java versions to install with SDKMAN

bash
sdk install java identifier

For example:

bash
sdk install java 17-tem

Switching Between Java Versions

If you have multiple versions installed, you can easily switch between them:

bash
sdk use java 11.0.20-tem

Viewing Installed Versions

To see all installed Java versions, use this command:

bash
sdk list java

Frequently asked questions

What is SDKMAN used for?

SDKMAN is a command-line tool for installing and switching between versions of Java and other JVM-related tools on Linux, macOS, or Windows with WSL.

Is SDKMAN similar to nvm?

Yes. It works like nvm does for Node.js, but for Java and other JVM tools.

How do I switch between installed Java versions?

Run sdk use java <version>, for example sdk use java 11.0.20-tem.

How do I see which Java versions I have installed?

Run sdk list java. Installed versions show up in that same list.

Comments