sdk install: Usage, Options & Common CI Errors
sdk install adds JVM ecosystem tools (Java, Gradle, Maven, Kotlin) via SDKMAN!.
SDKMAN! manages parallel versions of JVM tools. Its sdk command is a shell function, so - like nvm - CI must source SDKMAN! and disable interactive prompts.
What it does
sdk install <candidate> <version> installs a JVM tool (e.g. java 21-tem, gradle 8.8) under ~/.sdkman. sdk is a shell function loaded from sdkman-init.sh, so a non-interactive CI shell must source it. Setting sdkman_auto_answer makes installs non-interactive.
Common usage
curl -s "https://get.sdkman.io" | bash
echo 'sdkman_auto_answer=true' >> ~/.sdkman/etc/config
echo 'sdkman_selfupdate_feature=false' >> ~/.sdkman/etc/config
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 21.0.3-tem
sdk install gradle 8.8Common errors in CI
"sdk: command not found" - the non-interactive shell did not source $HOME/.sdkman/bin/sdkman-init.sh; do it at the top of the step. Without sdkman_auto_answer=true, prompts like "Do you want java ... to be set as default? (Y/n)" hang the job. "Stop! java 99 is not available." means an invalid version identifier - run sdk list java to see valid ones. sdk is a function, so each fresh CI step must re-source the init script.
Options
| Item | What it does |
|---|---|
| install <candidate> <version> | Install a specific tool version |
| default <candidate> <version> | Set the default version |
| use <candidate> <version> | Use a version in this shell |
| list <candidate> | List available versions |
| sdkman_auto_answer=true | Make installs non-interactive |