Created
April 25, 2011 12:47
-
-
Save magro/940463 to your computer and use it in GitHub Desktop.
Installs sun/oracle jdk stuff as alternatives, tested for fedora (14) 64bit (see also http://www.javakaffee.de/blog/2010/12/26/installing-java-on-fedora-using-alternatives/)
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/sh | |
# | |
# Installs sun/oracle jdk stuff as alternatives, tested for fedora (14) 64bit. | |
# See also http://www.javakaffee.de/blog/2010/12/26/installing-java-on-fedora-using-alternatives/ | |
# Author: martin(dot)grotzke(at)googlemail(dot)com | |
if [ $# -ne 3 ]; then | |
echo 1>&2 "Usage: $0 <major-version> <minor-version> <priority>" | |
echo "E.g. $0 1.6.0 2 20000" | |
exit 127 | |
fi | |
MAJOR=$1 | |
MINOR=$2 | |
PRIO=$3 | |
ARCH=`uname -m` | |
# The standard alternatives... | |
echo "Installing alternatives for java, javac and jar." | |
alternatives --install /usr/bin/java java /usr/java/jdk$MAJOR"_"$MINOR/jre/bin/java $PRIO | |
alternatives --install /usr/bin/javac javac /usr/java/jdk$MAJOR"_"$MINOR/bin/javac $PRIO | |
alternatives --install /usr/bin/jar jar /usr/java/jdk$MAJOR"_"$MINOR/bin/jar $PRIO | |
# And perhaps this is also useful | |
if [ -e /usr/java/jdk$MAJOR"_"$MINOR/jre/lib/amd64/libnpjp2.so ] | |
then | |
echo "Installing alternative for libjavaplugin.so.$ARCH." | |
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.$ARCH /usr/java/jdk$MAJOR"_"$MINOR/jre/lib/amd64/libnpjp2.so $PRIO | |
else | |
echo "/usr/java/jdk$MAJOR"_"$MINOR/jre/lib/amd64/libnpjp2.so does not exist - seems to be another architecture here. Check 32bit stuff." | |
echo "Skipping alternative for libjavaplugin.so.$ARCH." | |
fi | |
# This is the most important IMHO but kept secret on the web... | |
echo "Installing alternative for java_sdk_$MAJOR." | |
alternatives --install /usr/lib/jvm/java-$MAJOR java_sdk_$MAJOR /usr/java/jdk$MAJOR"_"$MINOR $PRIO | |
if [ -e /etc/profile.d/jdk.sh ] | |
then | |
echo "/etc/profile.d/jdk.sh already exists, won't modify it." | |
else | |
echo "Creating /etc/profile.d/jdk.sh." | |
echo "export JAVA_HOME=/usr/lib/jvm/java-$MAJOR" > /etc/profile.d/jdk.sh | |
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile.d/jdk.sh | |
fi | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment