2013-07-01

Switching between OpenJDK v.6 and v.7 in Debian 7 Wheezy


In Debian 7 Wheezy for the architecture amd64 (most of the modern 64-bit architectures) the default OpenJDK is OpenJDK v.6.

But what if you want OpenJDK v.7 (Java 7)?

Debian Wiki ( http://wiki.debian.org/Java ) already have the answer, what and how to do, but this answer mining should take you for a while...

Here is the howto.

First, open the terminal and
$ su -l

Now install the JDKs:
# aptitude install default-jdk default-jre openjdk-6-jre openjdk-6-jdk openjdk-7-jre openjdk-7-jdk java-common

This will take you for a while.

At Debian 7 the default JDK/JRE version is managed by the 'alternatives' system. So, to list the available (installed) JDKs, type:
# update-java-alternatives -l
The output will be like this:
java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64
java-1.7.0-openjdk-amd64 1051 /usr/lib/jvm/java-1.7.0-openjdk-amd64


Now let's switch to Java 7:
# update-java-alternatives -s java-1.7.0-openjdk-amd64

That's all!

Please, check the Java version:
$ java -version
$ javac -version
In both cases, the versions should be like 1.7.*

Enjoy!