asdf is a helpful command-line tool that allows you to manage and switch between different versions of programming language runtimes including
Python and their associated packages and libraries including
Spring Boot CLI.
asdf is supported for all major operating systems including Windows via Windows Subsystem for Linux 2 (WSL2).
Depending on your setup (OS, shell and installation method) you need to perform several steps in order to make sure
asdf works correctly. Consult the documentation for more details: https://asdf-vm.com/guide/getting-started.html.
I work on macOS with
oh-my-zsh, so the setup was to install
brew install asdf) and then to install
Install and manage Java versions
Once you have
asdf installed, you can use the following steps to install and manage
- Add the
asdf plugin add java.
- List all available
Javaversions by running:
asdf list all java. Tip: Pipe the command with
grepif you are looking for specific runtime.
- Use the
asdf installcommand to install a specific
Javaversion. For example, to install
Java 19support, you would run
asdf install java graalvm-22.3.0+java19:
➜ ~ asdf install java graalvm-22.3.0+java19 ###################### 100.0% graalvm-ce-java19-darwin-amd64-22.3.0.tar.gz graalvm-ce-java19-darwin-amd64-22.3.0.tar.gz: OK
- Use the
asdf globalcommand to set the default version of
Javato use on your machine. For example, to set previously installed version as the default version, you would run
asdf global graalvm-22.3.0+java19:
➜ ~ asdf global java graalvm-22.3.0+java19 ➜ ~ java -version openjdk version "19.0.1" 2022-10-18 OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 19.0.1+10-jvmci-22.3-b08) OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 19.0.1+10-jvmci-22.3-b08, mixed mode, sharing)
Global defaults are managed in
➜ ~ tail $HOME/.tool-versions java graalvm-22.3.0+java19
In contrary, when you want to use version specific to a directory you would use
asdf local command which creates
$PWD/.tool-versions file. Now, each you navigate to that directory,
asdf picks the versions and set them properly for this directory only.
Install other tools
There are many language runtimes and tools you can manage with
asdf. The process is as follows:
- You look for the plugin (e.g.
asdf plugin list all | grep gradle)
- You add the plugin (e.g.
asdf plugin add gradle)
- You find the version you want to manage (e.g.
asdf list all gradle)
- You install the selected version of langugate runtime or tool (e.g.
asdf install gradle 7.6)
Before I discovered
asdf, I used
SDKMAN! is a tool for managing parallel versions of multiple SDKs and once installed, it provides a convenient
sdk command for installing, switching, removing and listing installed SDKs. Learn more about it from my blog post: Manage multiple Java SDKs with SDKMAN! with ease