(JDK) Java Development Kit (JRE) Java Runtime Environment Standard Edition (JavaSE) Enterprise Edition (JavaEE, also known as J2EE), Mobile Edition (JavaME)

How to install Oracle Java

Download and extract Oracle JDK to the /opt/jdk like path, and then:

$ sudo update-alternatives --install /usr/bin/java java /opt/jdk/jre/bin/java 2000
$ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/bin/javac 2000

Install Java on ubuntu

$ 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:

$ apt-get install default-jdk