Files
oam/knowledge base/sdkman.md
2024-04-08 18:21:26 +02:00

2.4 KiB

SDKMAN

  1. TL;DR
  2. Further readings
    1. Sources

TL;DR

Management

Configuration file: ${HOME}/.sdkman/etc/config

# Install.
curl -s "https://get.sdkman.io" | bash
export SDKMAN_DIR="/path/to/custom/location" && curl -s "https://get.sdkman.io" | bash
curl -s "https://get.sdkman.io?rcupdate=false" | bash

# Initialize.
source "$HOME/.sdkman/bin/sdkman-init.sh"

# Get help.
sdk help
sdk help 'install'

# Show the current SDKMAN version.
sdk version

# Change configuration values.
# Opens the editor defined by the 'EDITOR' variable.
sdk config

# Install a new version of SDKMAN! if available.
sdk selfupdate
sdk selfupdate force

# Uninstall.
# The initialization snippet must also be removed from the shells' RC dotfiles.
tar zcvf "${HOME}/sdkman-backup_$(date +%F-%kh%M).tar.gz" -C "$HOME" '.sdkman' \
&& rm -rf "${HOME}/.sdkman"
Usage
# List available candidates.
sdk list
sdk list 'groovy'

# Install versions.
# When not given a version, 'latest' is implied.
sdk install 'java'
sdk install 'scala' '3.4.1'
sdk install 'java 17-zulu' '/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home'

# Show the currently used versions.
sdk current
sdk current 'java'

# Use specific versions in the current shell session.
sdk use 'scala' '3.4.1'

# Make versions the default.
sdk default 'scala' '3.4.1'

# Generate '.sdkmanrc' files.
# Those files work like `asdf`'s '.tool-versions' files.
sdk env init

# Install missing versions.
sdk env install

# Switch to the configuration defined by the '.sdkmanrc' file in the current directory.
sdk env

# Reset the versions to the default ones.
sdk env clear

# Get the absolute path of versions.
sdk home 'java' '21.0.2-tem'

# Flush the local state.
sdk flush

# Toggle online/offline mode.
sdk offline enable
sdk offline disable

# Refresh the available versions.
sdk update

# Upgrade versions.
sdk upgrade
sdk upgrade 'springboot'

# Remove installed versions.
sdk uninstall 'scala' '3.4.1'

Further readings

Sources