Skip to content

Instantly share code, notes, and snippets.

@speedlog
Last active April 23, 2022 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speedlog/c96ed2c40588c0482ea7123a5ae2f241 to your computer and use it in GitHub Desktop.
Save speedlog/c96ed2c40588c0482ea7123a5ae2f241 to your computer and use it in GitHub Desktop.
Alias for use any patch and distribution of specific java version (using sdkman)
# Alias for use any patch and distribution of specific java version (using sdkman)
# usage sdkj 17
# Source: https://gist.github.com/speedlog/c96ed2c40588c0482ea7123a5ae2f241
alias sdkj='_sdkman_use_any_java(){ java_sdkman=$(find ~/.sdkman/candidates/java -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | grep "^$1" | sort -r | head -n1) && if [[ -z $java_sdkman ]]; then echo "Cant find java $1 installed by sdkman"; return; fi && source "$HOME/.sdkman/bin/sdkman-init.sh" && sdk use java $java_sdkman; }; _sdkman_use_any_java'
@speedlog
Copy link
Author

Script for install alias in bash

curl https://gist.githubusercontent.com/speedlog/c96ed2c40588c0482ea7123a5ae2f241/raw/c625bf9025634b4ee94336f8d1bd89276c9b68b0/sdk_use_any_java.sh >> ~/.bashrc
source ~/.bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment