Installing Oracle JAVA 7 on Debian Wheezy

A quick how-to install Oracle's JAVA 7 on Debian 7 (Wheezy). If you're looking on how to install and configure Oracle's JAVA on CentOS 6 then please refer here. You can have both as I have on my Debian Wheezy, the open-source version of JAVA that is known as Icedtea and the one from Oracle that I'm going to install now.

The issue for me was that the icedtea-plugin was not playing nice with DELL's DRAC Console and for my wife was that she was unable to watch some java applet played vids online.

Ok, nonetheless, let's first make sure the system is up-to-date

apt-get update
apt-get upgrade
apt-get dist-upgrade

I'm using 64bit [amd64] version of Debian 7, so if you're not, make sure you tune the commands accordingly. Also, the URLs may change, so make sure you verify that aswell . Always get the latest version from here

Download JAVA 7 from Oracle's website using wget

wget --no-cookies \
--header "Cookie:" \
"" \
-O /tmp/jdk-7-linux-x64.tar.gz --no-check-certificate

for 32 bit system you may use

wget --no-cookies \
--header "Cookie:" \
"" \
-O /tmp/jdk-7u51-linux-i586.tar.gz --no-check-certificate

Unpack the downloaded JAVA 7 archive in /opt

mkdir /opt/java-oracle
tar -zxf /tmp/jdk-7-linux-x64.tar.gz -C /opt/java-oracle

for 32 bit system use this instead

tar -zxf /tmp/jdk-*-linux-i586.tar.gz -C /opt/java-oracle

Set-up Oracle's JAVA 7 to be used on the system by using higher priority with update-alternatives

update-alternatives --install /usr/bin/java java ${JHome%*/}/bin/java 20000
update-alternatives --install /usr/bin/javac javac ${JHome%*/}/bin/javac 20000

re-check JHome=/opt/java-oracle/jdk1.7.0_51 is set to the correct directory

Verify or set Oracle's JAVA 7 to be used as a default JAVA on the system

update-alternatives --config java

There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection Path Priority Status
  0 /opt/java-oracle/jdk1.7.0/bin/java 20000 auto mode
  1 /opt/java-oracle/jdk1.7.0/bin/java 20000 manual mode
  2 /opt/java-oracle/jdk1.7.0_45/bin/java 20000 manual mode
* 3 /opt/java-oracle/jdk1.7.0_51/bin/java 20000 manual mode
  4 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode

check JAVA version using

java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

64bit system

to enable JAVA plugin in chrome/chromium, do

mkdir /opt/google/chrome/plugins
ln -sf /opt/java-oracle/jdk1.7.0_51/jre/lib/amd64/ /opt/google/chrome/plugins/

to achieve the same in firefox run

ln -sf /opt/java-oracle/jdk1.7.0_51/jre/lib/amd64/ /usr/lib/firefox-addons/plugins/

Rob Sargeant threw $.02 on this. (thanks Rob). He had to do:

cd /usr/lib/
mkdir firefox-addons plugins
cd plugins
ln -sf /opt/java-oracle/jdk1.7.0_51/jre/lib/i386/ /usr/lib/firefox-addons/plugins/

to enable the JAVA plugin in his firefox