Thursday, November 7, 2013

Update oracle java on debian linux

i recently ran into a situation where i needed to update java on my debian linux system. this update needed to include the java plugin for my firefox browser, which is a security vector, but is required for some work tasks. my setup is NOT using the default openjdk package that debian provides. i prefer to use oracle java. i wrote a bash script to make all the required calls to update-alternatives to complete the update. below are the steps i followed.

i downloaded the necessary jdk linux tarball from http://www.oracle.com/technetwork/java/javase/downloads/index.html to /share.


>su -
>mkdir /usr/local/src/java
>cp /share/jdk-7u##-linux-i586.tar.gz /usr/local/src/java
>cd /usr/local/src/java
>tar -xvzf jdk-7u##-linux-i586.tar.gz
>bash /share/updateJava.sh
>exit



below are the contents of the script updateJava.sh :


# this script uses debian's update-alternatives to update
# to the latest version of java

javaRoot="/usr/local/src/java/jdk1.7.0_45/"

update-alternatives --install /usr/bin/java java "$javaRoot""bin/java" 1
update-alternatives --install /usr/bin/javac javac "$javaRoot""bin/javac" 1
update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so "$javaRoot""jre/lib/i386/libnpjp2.so" 1

update-alternatives --set java "$javaRoot""bin/java"
update-alternatives --set javac "$javaRoot""bin/javac"
update-alternatives --set mozilla-javaplugin.so "$javaRoot""jre/lib/i386/libnpjp2.so"


 



below is the output of my system:

>java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Server VM (build 23.21-b01, mixed mode)
 

>bash /share/updateJava.sh
update-alternatives: using /usr/local/src/java/jdk1.7.0_45/bin/java to provide /usr/bin/java (java) in manual mode
update-alternatives: using /usr/local/src/java/jdk1.7.0_45/bin/javac to provide /usr/bin/javac (javac) in manual mode
update-alternatives: using /usr/local/src/java/jdk1.7.0_45/jre/lib/i386/libnpjp2.so to provide /usr/lib/mozilla/plugins/libjavaplugin.so (mozilla-javaplugin.so) in manual mode
 

>java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)


info taken from:
http://www.redirecttonull.com/?p=250

No comments: