A quick how-to install Oracle’s JAVA 7 on Debian 7 (Wheezy).

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 \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.tar.gz" \
-O /tmp/jdk-7-linux-x64.tar.gz

for 32 bit system you may use

wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-i586.tar.gz" \
-O /tmp/jdk-7-linux-i586.tar.gz

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-7-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

JHome=/opt/java-oracle/jdk1.7.0_55
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_55 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_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

-> Original Source page <-