Skip to content

Instantly share code, notes, and snippets.

@luizrobertofreitas
Last active December 7, 2021 11:50
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 luizrobertofreitas/cc31f92563a43d03a7d40bbad734f89c to your computer and use it in GitHub Desktop.
Save luizrobertofreitas/cc31f92563a43d03a7d40bbad734f89c to your computer and use it in GitHub Desktop.
Change jdk script
#!/bin/bash
versions=(8 11)
if [ $# -eq 0 ]
then
echo "No arguments supplied. exiting"
exit 1
fi
if [[ " "${versions[@]}" " == *" "$1" "* ]] ;then
echo "changing to Jdk ${1}"
sudo rm /opt/jdks/java_home
sudo ln -s /opt/jdks/$1 /opt/jdks/java_home
java -version
else
echo "$1 not recognized. valid values are 8 and 11"
exit 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment