Sdkman

发布时间 2023-10-29 17:05:19作者: ivanohohoh

sdkman

Better software version management and software environment management than update-alternatives.

update-alternatives can only be used for version control, and sdkman can automatically set the JAVA_HOME environment variable.

Its principle is very simple, it will save all managed software under ~/.sdkman/candidates, and change the PATH variable very roughly to achieve the purpose

#$ sdk current
Using:
java: 14.0.2-zulu
gradle: 6.2.2
 Imagine dealing with multiple version of java

# Installing sdkman
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"

# List All SDK Candidates
# The list command shows all the available candidates, 
# identified by a unique name, the description, the official website, 
# and the installation command
$ sdk list
$ sdk list java

# Install and Manage Java Version
$ sdk install java Identifier                          # online
$ sdk install java _custome_identifier _path_to_target # localy

# Switching Between Versions
$ sdk use java Identifier         # temporarily
$ sdk default java 14.0.1.j9-adpt # permanently

# Remove a Version
$ sdk uninstall java 14.0.1.j9-adpt

# Display the Version in Use
$ sdk current java
$ sdk current

[ref1](Guide to SDKMAN! | Baeldung)