JAVA: How to install Java (JRE/JDK) on Ubuntu Machine
Installing default JRE/JDK
This is recommended and will install OpenJDK 6 on Ubuntu 12.04 and earlier and on 12.10+ it will install OpenJDK7.
* Installing java with apt-get is easy. First update the package
sudo apt-get update -y
* Then, check Java is installed or not java -version
If it returns "The program java can be found in the following packages" then you need to install it. For that you need to execute following command: sudo apt-get install default-jre
This install Java Runtime Environment(JRE)
* Now you will also need Java Development Kit (JDK) needed to compile Java applications(say Apache Ant , Apache Maven, Eclipse).
Execute the following command: sudo apt-get install default-jdk
This is everything need to install Java on Ubuntu Machine.