Its simple... Use the command
sudo apt-get install openjdk-7-jre
This will install JDK 1.7 on your ubuntu box. But there is a catch.. if you still run java -version, it will tell you that it is still using JDK 1.6.
So your system has actually been updated with JDK 1.7 but it is still not in use. There is a special script in ubuntu which allows you to check different versions present on the system and let's you choose the correct one you want to activate.
Here is how you can update that:
sudo update-alternatives --config java
This command will give you an output similar to below.. and asking you to choose which one you want to use..
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
Simple.. Isn't it?