This is the recommended and easiest option. This will install OpenJDK 7 on Ubuntu 14.04.
Installing Java with
apt-get is easy. First, update the package index:
sudo apt-get update
Then, check if Java is not already installed:
If it returns “The program java can be found in the following packages”, Java hasn’t been installed yet, so execute the following command:
sudo apt-get install default-jre
This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command:
sudo apt-get install default-jdk
That is everything that is needed to install Java.
All other steps are optional and must only be executed when needed.