Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Instructions:
- # Download the sun/oracle java .tar.gz package.
- # Extract the .tar.gz in your /opt/ directory.
- # In this script, edit XSUNJAVA= to point to the new directory in /opt
- # run this script
- # If it doesn't work, try to find out which variable is wrong (libDir, XOPENJDK, XSUNJAVA), and try again.
- # generic, extracted tarball:
- export XSUNJAVA=/opt/jdk1.7.0_04/
- # rpm install:
- # export XSUNJAVA=/usr/java/jdk1.7.0_04
- # Depending on if you have a 64 bit or 32 bit machine
- if [ -e /usr/lib64 ]; then
- libDir=/usr/lib64
- else
- libDir=/usr/lib
- fi
- # opensuse 12.1:
- export XOPENJDK="${libDir}/jvm/java-1.6.0-openjdk/"
- # opensuse 12.1 2012-07-04
- if [ ! -e $XOPENJDK ]; then
- export XOPENJDK="${libDir}/jvm/java-1.6.0-openjdk-1.6.0/"
- fi
- # ubuntu 12:
- # export XOPENJDK=/usr/lib/jvm/java-6-openjdk-amd64/
- update-alternatives --remove-all java
- update-alternatives --remove-all javac
- update-alternatives --remove-all keytool
- update-alternatives --remove-all javaplugin
- update-alternatives --remove-all javaws
- # Directories (for use in JAVA_HOME environment variable)
- update-alternatives --install /opt/java java_home ${XSUNJAVA} 1
- update-alternatives --install /opt/jdk jdk_home ${XSUNJAVA} 1
- update-alternatives --install /opt/java java_home ${XOPENJDK} 2
- update-alternatives --install /opt/jdk jdk_home ${XOPENJDK} 2
- update-alternatives --set java_home ${XSUNJAVA}
- update-alternatives --set jdk_home ${XSUNJAVA}
- # Commands using alternative directories
- update-alternatives --install /usr/bin/java java /etc/alternatives/jdk_home/bin/java 1
- update-alternatives --install /usr/bin/javac javac /etc/alternatives/jdk_home/bin/javac 1
- update-alternatives --install /usr/bin/keytool keytool /etc/alternatives/jdk_home/bin/keytool 1
- update-alternatives --install /usr/bin/javaws javaws /etc/alternatives/jdk_home/bin/javaws 1
- update-alternatives --set java /etc/alternatives/jdk_home/bin/java
- update-alternatives --set javac /etc/alternatives/jdk_home/bin/javac
- update-alternatives --set keytool /etc/alternatives/jdk_home/bin/keytool
- update-alternatives --set javaws /etc/alternatives/jdk_home/bin/javaws
- # For the browser plugin
- update-alternatives --install ${libDir}/browser-plugins/libnpjp2.so javaplugin /etc/alternatives/java_home/jre/lib/amd64/libnpjp2.so 1
- update-alternatives --install ${libDir}/browser-plugins/libnpjp2.so javaplugin ${libDir}/IcedTeaPlugin.so 2
- update-alternatives --set javaplugin /etc/alternatives/java_home/jre/lib/amd64/libnpjp2.so
- # add JAVA_HOME to current shell
- export JAVA_HOME=/etc/alternatives/java_home/
- # add JAVA_HOME to your environment
- if ! egrep -c "^JAVA_HOME=/etc/alternatives/java_home/$" /etc/profile >/dev/null 2>&1; then
- # ^ if the exact line we want is not in /etc/profile
- echo "Updating /etc/profile"
- # remove any JAVA_HOMEs in there
- egrep -v "^JAVA_HOME" /etc/profile > /etc/profile.javatmp
- # add JAVA_HOME
- echo "JAVA_HOME=$JAVA_HOME" >> /etc/profile.javatmp
- mv /etc/profile.javatmp /etc/profile
- echo "Done updating /etc/profile"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement