Created
July 29, 2013 18:41
-
-
Save the-dan/6106602 to your computer and use it in GitHub Desktop.
Add Sun/Oracle java as an alternative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# something in PATH env to lookup name in | |
LINK_PATH=/usr/bin | |
# where jdk is install to? | |
JDK_INSTALL_PATH=/opt/jdk1.7.0_21/bin | |
# alternative prefix | |
ALTER_PREFIX=oracle | |
ARGS= | |
OPT="--install" | |
for x in java javac keytool jstack jar jmap jhat; do | |
ARGS="$ARGS $OPT $LINK_PATH/$x $ALTER_PREFIX-$x $JDK_INSTALL_PATH/$x" | |
if [[ $x == "java" ]]; then | |
ARGS="$ARGS 1" | |
OPT="--slave" | |
fi | |
done | |
update-alternatives $ARGS | |
# update-alternatives --install /usr/bin/java oracle-java /opt/jdk1.7.0_21/bin/java 1 --slave /usr/bin/keytool oracle-keytool /opt/jdk1.7.0_21 /bin/keytool --slave | |
/usr/bin/javac oracle-javac /opt/jdk1.7.0_21/bin/javac --slave /usr/bin/jar oracle-jar /opt/jdk1.7.0_21/bin/jar --slave /usr/bin/jmap oracle-jmap /opt/jdk1.7.0_21/bin/jmap --slave /usr/bin/jstack oracle-jstack /opt/jdk1.7.0_21/bin/jstack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment