Table of contents
  1. Using SDKMan
  2. Install sdkman
  3. list candidates
  4. list versions
  5. will use for cmd shell only
  6. will switch default
  7. list all candidates
  8. available canidates
  9. Environment Switching




Using SDKMan

Install sdkman

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

list candidates

sdk list

list versions

sdk list [program]

will use for cmd shell only

sdk use [program] [version number]

will switch default

sdk default [program][version number]

list all candidates

ls -l ~/.sdkman/candidates/java

available canidates

Environment Switching

use a .sdkmanrc file at root of project

  • Use sdkman to run sdk env to initialize with correct JDK version
  • Enable auto-env through the sdkman_auto_env config
  • See https://sdkman.io/usage#config
  • Add sdkman_auto_env=true to ~/.sdkman/etc/config

my use case, contents of my .sdkmanrc file for GraalVM java project

# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=22.1.0.r17-grl
#java=17041-LibArch64