Mastering SDKMAN!: The Essential Tool for Spring Boot Developers
If you're a Spring Boot developer working on Ubuntu (or any Unix-like system), you've probably faced the headache of managing multiple Java versions, Maven releases, and other JVM-based tools. Enter SDKMAN! – a powerful command-line tool that eliminates version conflicts and makes switching between different SDK versions as simple as a single command.
What is SDKMAN!?
SDKMAN! (Software Development Kit Manager) is a version manager specifically designed for JVM-based tools and languages. Think of it as nvm
for Node.js, but tailored for the Java ecosystem. It allows you to install, manage, and switch between multiple versions of Java, Maven, Gradle, Spring Boot CLI, and dozens of other development tools without any conflicts.
Why SDKMAN! Matters for Spring Boot Development
When working on multiple Spring Boot projects, you often encounter scenarios like:
- Legacy projects requiring Java 8 or 11
- New projects leveraging Java 17 or 21
- Different Maven or Gradle versions across teams
- Experimenting with different JDK distributions (Oracle, Eclipse Temurin, GraalVM)
SDKMAN! solves these challenges by managing parallel installations and providing seamless switching mechanisms.
How SDKMAN! Works Under the Hood
SDKMAN! operates by:
- Downloading and installing SDKs to
~/.sdkman/candidates/
- Dynamically modifying your PATH through shell integration
- Using symbolic links and environment variables to switch versions
- Maintaining a local database of available versions from multiple vendors
This approach ensures that different versions coexist without interference, and switching between them is instant.
Essential SDKMAN! Commands
Basic Operations
# Update SDKMAN! itself
sdk update
# List all available SDKs
sdk list
# List specific SDK versions (e.g., Java)
sdk list java
# Show currently active versions
sdk current
# Show help
sdk help
Installation and Management
# Install latest stable version
sdk install java
# Install specific version
sdk install java 17.0.9-tem
# Install multiple essential tools
sdk install maven
sdk install gradle
sdk install springboot
# Show installed versions
sdk list java | grep installed
# Uninstall a version
sdk uninstall java 11.0.20-tem
# Upgrade all installed SDKs
sdk upgrade
Version Switching
# Use specific version for current shell session only
sdk use java 17.0.9-tem
# Set default version globally (affects all new shells)
sdk default java 17.0.9-tem
# Verify current setup
sdk current java
which java
java -version
Understanding Java Vendors in SDKMAN!
One of SDKMAN!'s strengths is supporting multiple JDK distributions. Here are the most common ones for Spring Boot development:
# Eclipse Temurin (recommended for most projects)
sdk install java 17.0.9-tem
# Oracle JDK
sdk install java 17.0.9-oracle
# GraalVM (for native compilation)
sdk install java 17.0.9-graal
# Amazon Corretto
sdk install java 17.0.9-amzn
Project-Specific Configuration
SDKMAN! supports project-specific SDK versions through .sdkmanrc
files:
# In your project root directory
echo "java=17.0.9-tem" > .sdkmanrc
echo "maven=3.9.5" >> .sdkmanrc
echo "gradle=8.4" >> .sdkmanrc
# Install versions specified in .sdkmanrc
sdk env install
# Switch to project-specific versions
sdk env
This approach ensures team consistency and eliminates "it works on my machine" issues.
Advanced Workflow Integration
Quick Environment Switching
# Temporarily switch Java for a specific task
sdk use java 11.0.20-tem && mvn clean package
# Switch back to default
sdk current java
Offline Mode
# Enable offline mode (useful for air-gapped environments)
sdk offline enable
# Disable offline mode
sdk offline disable
Cleanup and Maintenance
# List installed versions to identify old ones
sdk list java | grep installed
# Remove outdated patch versions
sdk uninstall java 11.0.19-tem
sdk uninstall java 17.0.8-tem
# Keep only latest patch versions for each major release
Best Practices for Spring Boot Projects
1. Standardize Team Environments
Create a .sdkmanrc
file in your project root and commit it to version control:
# .sdkmanrc
java=17.0.9-tem
maven=3.9.5
gradle=8.4
springboot=3.1.5
Team members can then run:
sdk env install
sdk env
2. Use Appropriate Java Versions
- Java 8: Legacy Spring Boot 2.x projects
- Java 11: Stable choice for Spring Boot 2.x/3.x
- Java 17: Recommended for new Spring Boot 3.x projects
- Java 21: Latest LTS, for cutting-edge projects
3. Verify Your Setup
Always verify your environment before building:
sdk current
java -version
mvn -version
./gradlew -version
Common Gotchas and Solutions
Shell Integration Issues
- Problem: Commands not recognized after installation
- Solution: Open a new terminal or run
source ~/.sdkman/bin/sdkman-init.sh
IDE Configuration
- Problem: IDE still uses system Java
- Solution: Manually configure IDE to use SDKMAN! Java path (
~/.sdkman/candidates/java/current
)
Wrapper Script Conflicts
- Problem: Maven/Gradle wrapper overrides SDKMAN! versions
- Solution: This is expected behavior. Wrappers ensure build reproducibility.
Version Confusion
- Problem: Forgetting which version is active
- Solution: Use
sdk current
frequently, or add SDK info to your shell prompt
Troubleshooting Commands
# Check what's actually being used
which java
which mvn
which gradle
# Verify SDKMAN! installation
sdk version
# Reset to system defaults (if needed)
sdk default java system
Conclusion
SDKMAN! transforms SDK management from a tedious chore into a seamless part of your development workflow. For Spring Boot developers juggling multiple projects with different requirements, it's an indispensable tool that eliminates version conflicts and ensures consistent environments across teams.
The key to mastering SDKMAN! is understanding the difference between temporary (sdk use
) and permanent (sdk default
) version changes, leveraging project-specific .sdkmanrc
files, and maintaining good cleanup practices.
Start with the essential tools for Spring Boot development:
sdk install java 17.0.9-tem
sdk install maven
sdk install gradle
sdk install springboot
sdk default java 17.0.9-tem
From there, explore additional tools and versions as your projects demand. Your future self (and your teammates) will thank you for the consistency and reliability that SDKMAN! brings to your development environment.
References and Useful Links
Official Documentation
- SDKMAN! Official Website
- SDKMAN! Installation Guide
- SDKMAN! Usage Documentation
- SDKMAN! Vendors Guide