Installing Java 7 on Debian
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 extrat it. I have to do it because at the moment the is no official debain package for java 7. So we are not able to do it with apt-get as we can it for java 6.
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</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 save somebody some setup time.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
Comments
Thank You very much. I installed JDK 7 and it works good. But I’m a little bit disappointed. My primary goal in installing 7 was to increase performance (I’ve read that it is much faster than JDK 6). But after installation I run a small benchmark (mainly memory operations: allocation, array copy and GC). I was disenchanted. JDK 7 is not faster than 6, but it appears a little bit slower ![]()
Average from 10 runs:
JDK 6: 704 [ms]
JDK 7: 715 [ms]
Maybe the next updates will be faster (now I use JDK 7u1).
Halle Mateusz,
creation of good benchmark is not so simple as it may appear. There are things like HotSpot Dynamic Compilation, garbage collection and other performance and resource management of vm that shold be considered, but can’t be measured 100%.
I any case you have to skip the warm up Phase in your benchmark and please dont’ expect to much by such benchmarks (Rule 0).
You are invited to post your benchmark code here and we can try it on our self or maybe improve it.
P.S. difference in 11ms is still Ok due typical System.currentTimeMillis() accuracy which is typical +- 15 ms on most OS + JVM combinations ![]()
Thanks a lot!!
I was trying to find a way how to install Java in Debian testing. Finally i could make it, all thanks to your explanation.
It works perfect for dummies like me. Thanks!
Get the new Java 7 Update 3 with:
wget http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.tar.gz




Hi, great post, it really helps
It only has a small “bug” in there, that i took about 30 mints to find. In the second line of the “update-alternatives” you have java when it should be javac. Like this:
update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 1065