How can I install Java 8 on Ubuntu 18.04?. How to install Java 8 on Ubuntu 16.04?. It is easy to install Java 8 on Ubuntu 18.04 & Ubuntu 16.04. As of this writing, the most recent release of Java is version 11.
We had done an article on installing Java 11 on Ubuntu 18.04/16.04 and Debian 9:
Java is the most popular class-based object-oriented programming language used mostly for building enterprise applications; both the desktop applications and backend web systems.
Programs written in Java are considered to be portable, scalable and simpler to understand. Java also enjoys a huge community of users both in Github, blogs and Stack Overflow.
Install Java 8 on Ubuntu 18.04 / Ubuntu 16.04
You can install Java 8 on Ubuntu 18.04 / Ubuntu 16.04 from OpenJDK binaries available on the default upstream repositories. To do this, run the command:
sudo apt install openjdk-8-jdk
Confirm Java Version
$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
Installing Java 8 from PPA repository
By using Webupd8 Team’s PPA repository, Java 8 can be installed using apt command. But first, the repository needs to be added to your Ubuntu system.
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
When the repository is added, install Java 8 by executing the following command in your terminal.
sudo apt install oracle-java8-installer
To install Java 8 and make the the default on the fly, run the following command instead.
sudo apt install oracle-java8-set-default
Set Default Java version
If you keep switching between different versions of Java, here is a guide for you on how to do it properly.