How to Install Java on Ubuntu

Before installing Java on Ubuntu you need to choose between Open JDK and Oracle JDK.

The difference is described here.

Personally, I prefer Oracle JDK.

Oracle JDK

To install Java on Ubuntu you need to open Terminal (Alt + Ctrl + T) and type:

This will add a PPA repository that contains Java installer.

Then if you want to install Java 8 execute a command:

If you want to install Java 9 execute:

The same is for Java 11:

So Java is installed.

You can check Java version by typing:



It’s not necessary to add any additional PPA repositories to install Open JDK on Ubuntu.

Just update a package index:

and install a default-jdk package:

Check Java version by typing:

Scroll Up