Skip to content

Instantly share code, notes, and snippets.

View tfield's full-sized avatar

Tony Field tfield

View GitHub Profile
@tfield
tfield / sdkman-vs-jenv.md
Last active May 30, 2024 02:12
SDKMAN vs JENV

sdkman vs jenv

Jenv is great, but the JDKs have to be manually installed. If you need more than just a couple of them, you'll want to be able to install them via command line, and sdkman provides this capability very cleanly for java. So... is it possible to work with both sdkman and jenv? Yes and no. Some tricks will allow you to tell jenv about the java versions that are managed by sdkman, but setting defaults (using jenv local 17.0 for instance) does not work very well. Time for a cleaner solution. Sdkman provides all of the same functionality, with more power and a slightly different (but equally simple) syntax. I've switched from jenv to sdkman. Here's my cheat sheet.

Setup

Download and install sdkman. Follow the required instructions after installing. Then, run the config command to enable auto_env support.

echo “Installing SDKMAN"
curl -s https://get.sdkman.io | bash
#!/bin/bash
echo "ensuring that jenv config directories exist"
mkdir -p $HOME/.jenv/versions
echo "removing current jenv java's to re-add them freshly"
jenv versions --bare | xargs -n1 jenv remove
echo "adding all sdkmans java versions to jenv"
find $HOME/.sdkman/candidates/java -maxdepth 1 -mindepth 1 -type d -exec jenv add '{}' \;