Posted by & filed under Java, Linux, Software.

Here is just an example of how to install java 7 on your linux.
I use current Debian and oracle (former sun) java 7.

First i had to download the latest java from oracle site and then extract it. I have to do it because at the moment the is no official debian package for java 7.
So we are not able to do it with apt-get as we can it for java 6.

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

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

java -version
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 save somebody some setup time.

Share if you likeTweet about this on TwitterShare on FacebookShare on Google+Share on RedditShare on LinkedInBuffer this pageEmail this to someone