Table Of Content

Installing and Configuring Java on Ubuntu

1- Introduction

In the post, I show you the way to install Java on Ubuntu (Server or Desktop), using the command.
If you use Ubuntu Desktop, you can open Terminal to execute the commands.

2- Install Java

To install Java easily on Ubuntu, the members of create a PPA (Personal Package Archive) which helps you to be able to download and automatically install Java directly from Oracle's website. It supports the java with the version of 6, 7, 8.
Firstly, you run the following command to add PPA Repository to your system.

sudo add-apt-repository ppa:webupd8team/java
Note: If you get error: "sudo: add-apt-repository: command not found", run the following commands:
sudo apt-get install software-properties-common

sudo add-apt-repository ppa:webupd8team/java
Then, run the following command to update the set of packages.

sudo apt-get update

Installing Java

To install Java 8, use the command:

sudo apt-get install oracle-java8-installer
Note: Replace number 8 with 6 or 7 if you want to install Java 6 or Java 7.
Java has been installed successfully.
You can execute the following command to check the version of Java that has already been installed.

java -version