Skip to content

Instantly share code, notes, and snippets.

@deepankarb
Created August 31, 2017 08:58
Show Gist options
  • Save deepankarb/5761bd1891ec30c8784de50ae68c733e to your computer and use it in GitHub Desktop.
Save deepankarb/5761bd1891ec30c8784de50ae68c733e to your computer and use it in GitHub Desktop.
Add an alternative JDK
if [ -z "$1" ]
then
echo "Please specify JDK path"
exit 1
fi
if [ -z "$2" ]
then
PRIORITY=100
else
PRIORITY="$2"
fi
echo "Priority: "$PRIORITY
JDK_PATH="$1"
for app in `find "$JDK_PATH/bin" -type f -executable`
do
app_name=$(basename $app)
man="$app_name"".1"
man_alt="$JDK_PATH""/man/man1/""$man"
man_path="/usr/share/man/man1/$man"
update-alternatives --verbose --install /usr/bin/"$app_name" "$app_name" "$app" "$PRIORITY" \
--slave "$man_path" "$man" "$man_alt"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment