Skip to content

Instantly share code, notes, and snippets.

@coenraadhuman
Created November 19, 2021 07:45
Show Gist options
  • Save coenraadhuman/6073450737182957a934f7b67bf73eda to your computer and use it in GitHub Desktop.
Save coenraadhuman/6073450737182957a934f7b67bf73eda to your computer and use it in GitHub Desktop.
Switch between Java versions installed on Ubuntu Based Linux
#!/usr/bin/env bash
set -euo pipefail
function main() {
must_root
sudo update-alternatives --config java
}
function must_root() {
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
}
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment