Skip to content

Instantly share code, notes, and snippets.

@MartinSeeler
Created December 29, 2013 19:05
Show Gist options
  • Save MartinSeeler/8173632 to your computer and use it in GitHub Desktop.
Save MartinSeeler/8173632 to your computer and use it in GitHub Desktop.
Some utility scripts for the commandline in Linux.
#!/bin/zsh
if [[ -z $1 ]]; then
echo "Please specify the home path of your jdk!"
exit
fi
if [[ ! (-d $1) ]]; then
echo "The directory to the jdk does not exist!"
exit
fi
HOME_PATH=$1
BIN_PATH=$HOME_PATH/bin
if [[ ! (-d $BIN_PATH) ]]; then
echo "There is no bin directory in your jdk home!"
exit
fi
BINARIES=(java javac javaws jar jarsigner javadoc jvisualvm)
echo "Installing Oracle JDK from ${HOME_PATH}"
${BIN_PATH}/java -version
for binary in $BINARIES
do
if [[ -a $BIN_PATH/$binary ]]; then
echo "Installing ${binary}..."
sudo update-alternatives --install "/usr/bin/${binary}" "${binary}" "${BIN_PATH}/${binary}" 1
sudo update-alternatives --set "${binary}" "${BIN_PATH}/${binary}"
else
echo "Can not find ${BIN_PATH}/${binary}!"
fi
done
echo "That's it!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment