Open JDK is the open source version of Java 7 environment. The following commands installs the runtime environment (JRE), the development environment (JDK), and browser plugin.

sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk
sudo apt-get install icedtea-7-plugin

Reference: https://help.ubuntu.com/community/Java