DEV Community

Clever Cottonmouth
Clever Cottonmouth

Posted on

Hurry up! Check SDKMAN for java development

SDKMAN! – The Best Tool for Managing Java Versions
Introduction
If you often need to switch between Java Development Kit (JDK) versions for multiple projects, you know how time-consuming it can be. Manually installing and switching JDKs is tedious and frustrating. SDKMAN! (Software Development Kit Manager) provides a simple and efficient way to install, manage, and switch between various JDK versions effortlessly.

Without this tool, comparing different Java versions can be a real pain! All those endless changes to JAVA_HOME—ahhh!

What is SDKMAN!?
SDKMAN! is a command-line tool that allows developers to easily install and manage various software development kits (SDKs), including Java, Kotlin, Scala, and more. It works on macOS, Linux, and Windows (WSL) and supports multiple Java vendors, including OpenJDK, Oracle JDK, GraalVM, and Zulu.

How to Install SDKMAN!
Installing SDKMAN! is straightforward. Open a terminal and run:

curl -s https://get.sdkman.io | bash
Enter fullscreen mode Exit fullscreen mode

After installation, restart your terminal or run:

source "$HOME/.sdkman/bin/sdkman-init.sh"
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

sdk version
Enter fullscreen mode Exit fullscreen mode

If everything is set up correctly, you should see output similar to this:

SDKMAN!

script: 5.19.0

native: 0.5.0
Using SDKMAN! for Java Management
1️⃣ Installing Java Versions
Check available JDKs:

sdk list java
Enter fullscreen mode Exit fullscreen mode

To install a specific JDK version, use:

sdk install java 23.0.2-graalce
Enter fullscreen mode Exit fullscreen mode

2️⃣ Switching Between Java Versions
To temporarily switch to a different Java version, use:

sdk use java 17.0.8-tem
Enter fullscreen mode Exit fullscreen mode

To set a default version for all projects:

sdk default java 23.0.2-graalce
Enter fullscreen mode Exit fullscreen mode

3️⃣ Setting Project-Specific Java Versions
Inside your project directory, initialize SDKMAN!'s environment:

sdk env init
Enter fullscreen mode Exit fullscreen mode

This creates a .sdkmanrc file with default content like this:

Enable auto-env through the sdkman_auto_env config

Add key=value pairs of SDKs to use below

java=23.0.2-graalce
Edit this file to specify your required Java version. Then activate it with:

sdk env
Now, every time you enter the project directory, SDKMAN! will automatically switch to the correct JDK version!

Why Use SDKMAN!?
✅ Simple Installation & Updates – Install and update SDKs with a single command.

✅ Supports Multiple JDK Vendors – OpenJDK, GraalVM, Zulu, Oracle JDK, etc.

✅ Instant Switching – No need to modify system variables manually.

✅ Project-Specific Environments – Automatically switches JDK versions per project.

SDKMAN! vs. Other Tools
| Feature | SDKMAN! | Homebrew + jEnv | ASDF |
|----------------------------------|---------|-----------------|------|
| Supports multiple JDK vendors | ✅ | ❌ (Only OpenJDK) | ✅ |
| Project-specific Java versions | ✅ | ✅ | ✅ |
| Works on macOS/Linux/WSL | ✅ | ✅ | ✅ |
| Manages other SDKs (Scala, Kotlin, etc.) | ✅ | ❌ | ✅ |

Conclusion
SDKMAN! is an essential tool for Java developers, making JDK management effortless. Whether you're working with OpenJDK, GraalVM, or another distribution, SDKMAN! lets you install, switch, and manage Java versions easily.

This tool has personally helped me compare different Java runtime versions and saved me a ton of time when migrating multiple projects from one version to another. If you're tired of constantly tweaking JAVA_HOME, give SDKMAN! a try!

Top comments (0)