Skip to content

Instantly share code, notes, and snippets.

@uuklanger
Last active November 11, 2020 23:08
Show Gist options
  • Save uuklanger/87607b3b7b4765197660de237f926dbf to your computer and use it in GitHub Desktop.
Save uuklanger/87607b3b7b4765197660de237f926dbf to your computer and use it in GitHub Desktop.
remove_old_alternative.sh
# ---------------------------------------------------------------
# If you are setting up a clean (never used) system, you can run this full batch
# Otherwise, I suggest running this line by line (copy/paste).
#
# Show if java, javac, or jar are already setup. Run these commands before running the rest
#
JDK_VERSION='jdk1.8.0_261'
echo "==============================================================="
echo " Processing Aternatives for "${JDK_VERSION}
echo "==============================================================="
echo "Querying current values"
sudo update-alternatives --query java
sudo update-alternatives --query javac
sudo update-alternatives --query jar
sudo update-alternatives --query keytool
sudo update-alternatives --query jarsigner
#
# Setup alternatives so java, javac, and jar are in the path. Run what is missing based on above.
#
echo "==============================================================="
echo "Installing current values"
echo "==============================================================="
sudo update-alternatives --remove java /usr/lib/jvm/${JDK_VERSION}/bin/java
sudo update-alternatives --remove javac /usr/lib/jvm/${JDK_VERSION}/bin/javac
sudo update-alternatives --remove jar /usr/lib/jvm/${JDK_VERSION}/bin/jar
sudo update-alternatives --remove keytool /usr/lib/jvm/${JDK_VERSION}/bin/keytool
sudo update-alternatives --remove jarsigner /usr/lib/jvm/${JDK_VERSION}/bin/jarsigner
#
# Visually confirm (that means you) that java, javac, and jar are setup
#
echo "==============================================================="
echo "Querying current values"
echo "==============================================================="
sudo update-alternatives --query java
sudo update-alternatives --query javac
sudo update-alternatives --query jar
sudo update-alternatives --query keytool
sudo update-alternatives --query jarsigner
#
# DONE
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment