Skip to content

Instantly share code, notes, and snippets.

@cnicodeme
Created December 3, 2013 11:11
Show Gist options
  • Save cnicodeme/7767504 to your computer and use it in GitHub Desktop.
Save cnicodeme/7767504 to your computer and use it in GitHub Desktop.
Simple script that add Java support in update-alternative. Takes the latest folder in /opt/java as the reference.
#!/bin/bash
# First of all, we check if the user is root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
update-alternatives --install /usr/bin/java java /opt/java/$(ls -tr | tail -1)/bin/java 1
update-alternatives --install /usr/bin/javac javac /opt/java/$(ls -tr | tail -1)/bin/javac 1
update-alternatives --install /usr/bin/javadoc javadoc /opt/java/$(ls -tr | tail -1)/bin/javadoc 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment