Created
November 19, 2021 07:45
-
-
Save coenraadhuman/6073450737182957a934f7b67bf73eda to your computer and use it in GitHub Desktop.
Switch between Java versions installed on Ubuntu Based Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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