Install openjdk7 on Debian 7

The default JDK on Debian 7 is openjdk6, but it's so easy to install openjdk7:

1. Install

apt-get update
apt-get install openjdk-7-jre

Install source code:

sudo apt-get install openjdk-7-source

All the JDK versions can be found at /usr/lib/jvm/

2. Choose openjdk7 as the default JDK

update-alternatives --config java


cd /usr/lib/jvm
rm default-java
ln -s java-7-openjdk-amd64/ default-java

3. Add JAVA_HOME to your environment

append the following code to ~/.bashrc

export JAVA_HOME
export PATH

(you can also append the above as a global setting in /etc/profile)

and then run this to active bash setting immediately:

source ~/.bashrc