Master Multi‑Version Java Management with SDKMAN: Install, Switch, and Upgrade

This article explains why managing multiple Java versions is necessary, introduces SDKMAN as a cross‑platform tool, and provides step‑by‑step commands for installing, listing, switching, setting defaults, flushing caches, and uninstalling SDKMAN on Unix‑like systems and Windows.

Programmer DD
Programmer DD
Programmer DD
Master Multi‑Version Java Management with SDKMAN: Install, Switch, and Upgrade

Introduction

Java releases new versions frequently; developers often need to handle several versions simultaneously for new features or project compatibility. Oracle's licensing changes after Java 11 also motivate the use of OpenJDK distributions.

Since Java 11 Oracle requires a commercial license for production use, many developers prefer OpenJDK alternatives.

Managing a single Java environment variable is trivial, but handling multiple versions with traditional methods is cumbersome.

Multi‑Version Java Management

Common solutions include:

Jabba ( https://github.com/shyiko/jabba )

jenv ( https://github.com/jenv/jenv )

SDKMAN ( https://sdkman.io/ )

This guide focuses on using SDKMAN to simplify Java version management.

What Is SDKMAN?

SDKMAN is a command‑line tool for Unix‑like systems that manages parallel versions of software development kits such as Java, Groovy, Scala, Kotlin, Ant, Gradle, and more.

It provides commands to install, switch, remove, and list candidates.

Installing SDKMAN

Run the following commands in a terminal: $ curl -s "https://get.sdkman.io" | bash Follow the prompts, then initialize the environment: $ source "$HOME/.sdkman/bin/sdkman-init.sh" Verify the installation:

$ sdk version

SDKMAN checks for updates each time sdk version runs; press y to upgrade.

If zip or unzip are missing, install them: $ sudo apt-get install zip unzip The default installation directory is $HOME/.sdkman, but you can change it by setting SDKMAN_DIR before installation.

$ export SDKMAN_DIR="/usr/local/sdkman" && curl -s "https://get.sdkman.io" | bash

SDKMAN Usage Tutorial

Start with the help command:

$ sdkman help

Listing Candidates

$ sdk list

To see Java versions:

$ sdk list java

Installing a Version

Install the latest Java 13.0.1.j9: $ sdk install java 13.0.1.j9 Use the identifier shown by sdk list java if the version label is unavailable.

Checking Current Version

$ sdk current java

Switching Versions

$ sdk use java 12.0.2.j9-adpt

Setting Default Version

$ sdk default java jdk1.8.0_162.jdk

Uninstalling a Version

$ sdk uninstall java 12.0.2.j9-adpt

Upgrading a Candidate

$ sdk upgrade java

Flushing Caches

Clear broadcast messages, archives, and temporary files:

$ sdk flush broadcast
$ sdk flush archives
$ sdk flush temp

Use sdk help anytime to view available commands.

Uninstalling SDKMAN

Backup and remove the SDKMAN directory:

$ tar zcvf ~/sdkman-backup_$(date +%F-%kh%M).tar.gz -C ~/ .sdkman
$ rm -rf ~/.sdkman

Delete the initialization lines from your shell profile files (e.g., .bashrc, .zshrc).

SDKMAN on Windows

The SDKMAN website provides a Windows‑compatible solution; users can follow the instructions there.

Soul‑Searching Questions

What Java version are you currently using?

Do you experiment with new features in newer releases?

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Javacommand-lineUnixInstallationversion-managementSDKMAN
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.