How to install java 7 on your Linux. Below you will find Oracle (former Sun) java 7 installed on Debian Linux

At the moment there is no official debian (and linux at all) package (de) for java 7 and apt-get is not working for us, like previously with open jdk. Firstly we have to download the latest java from oracle site and then extract it.

wget http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz
tar zxvf jdk-7-linux-x64.tar.gz -C /usr/lib64/jvm/

Then we have to do some configuration. Debian Linux has useful script to maintain different version of one programs like java called update-altenatives, so i simply use this.

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/bin/java 1065
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 1065

Where 1065 is a given priority. To check my installation i use--config paramter.

update-alternatives --config java
#this prints:
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk1.7.0/bin/java             1065      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/jdk1.7.0/bin/java             1065      manual mode&lt;/pre&gt;</code></pre>

And because 1065 is higher than 1061, the fresh installed java 7 will be used by default on my machine

java -version
#prints:
java version "1.7.0"
 Java(TM) SE Runtime Environment (build 1.7.0-b147)
 Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

Hope this saves somebody some setup time.