Installing Sun Java 1.7.x in debian squeeze

Debian squeeze repository has java 1.6.x  and can be easily installed via apt command however, installing sun- java 1.7.x is pain in ass.Here I have complied the steps  for installing sun java 1.7.x  in Debian squeeze :

Download latest version or whatever is the preference  of java1.7.x by following following this post : Sun Java Download

Uncompress it .

JDK 7 package is extracted into ./jdk.1.7.x directory.Check carefully this folder name since Oracle seem to change this occasionally with each update.

Now move the JDK 7 directory to /usr/lib

sudo mkdir -p /usr/lib/jvm
sudo mv ./jdk.1.7.x /usr/lib/jvm/jdk1.7.0
Run :
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1

Correct the file ownership and the permissions of the executables:

sudo chmod a+x /usr/bin/java 
sudo chmod a+x /usr/bin/javac 
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0

Run :

sudo update-alternatives –config java

Shows java alternatives available debian and would show something like this:

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode
Press enter to keep the current choice[*], or type selection number: 3

Choose 3 or whichever points to java 1.7.x.

Check the java version via : java --version command .

Share this article


About the author