Install Oracle Java on Ubuntu 16.04. How to install Java (JDK) on Ubuntu, via Terminal. Commands to install the Java Runtime Environment (JRE) on Ubuntu 16.04.
You can easily install Java on Ubuntu Systems, using the version packaged. For example the following command will install OpenJDK 8:
sudo apt-get update
sudo apt-get install default-jre
Please note that above command will install the Java Runtime Environment (JRE). If you wish to install the JDK (Java Development Kit), run the following command:
sudo apt-get install default-jdk
You can also install the Oracle JDK bu WebUpd8 PPA:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Install Oracle JDK 6 or JDK 7
To install JDK 6 on Ubuntu 16.04, run the following command:
sudo apt-get install oracle-java6-installer
To install JDK 7 on Ubuntu 16.04, run the following command:
sudo apt-get install oracle-java7-installer
Install Oracle JDK 8
To install JDK 8 on Ubuntu 16.04, run the following command:
sudo apt-get install oracle-java8-installer
Install Oracle JDK 9
To install JDK 9 on Ubuntu 16.04, run the following command:
sudo apt-get install oracle-java9-installer
Please note that there may be multiple Java versions installed on one Ubuntu server. To configure which Jaa version to use, run the following command:
sudo update-alternatives --config java
Please note that many Linux distribution are shipped with OpenJDK, other version of Java. OpenJDK is not developed by Sun Microsystems, instead OpenJDK is an open source implementation of Java application.
Before you begin the installation, run the following command to verify the version of Java already installed on the system.
$ java -version