How To Install OpenJDK 8 on Ubuntu 18.04

Introduction

In this tutorial we learn how to install OpenJDK 8 on Ubuntu 18.04 from Ubuntu repository.

Update Apt Package Index

First of all update apt package index using the command below.

sudo apt-get update

alternatively, we can also use apt command below.

sudo apt update

Searching OpenJDK Packages on Ubuntu Repository

To get list of available OpenJDK packages we can use command below.

sudo apt search ^openjdk-8

We will get output similar to below.

install openjdk 8 ubuntu 18.04 - apt search openjdk-8

To search OpenJDK packages on Ubuntu we can also use apt-cache command below.

sudo apt-cache search ^openjdk

The output will be a little bit different that what we got from apt search command.

You can see sample output of this search below.

install openjdk 8 on Ubuntu 18.04 - apt-cache search openjdk-8

Install OpenJDK 8 on Ubuntu 18.04

In this section we learn how to install OpenJDK 8 on Ubuntu 18.04. We will learn how to setup multiple alternatives of OpenJDK 8 on Ubuntu 18.04

Install OpenJDK 8 Java Development Kit (JDK)

To install OpenJDK 8 JDK package we can use the command below.

sudo apt-get install openjdk-8-jdk

To install OpenJDK 8 JDK headless package we can use the command below.

sudo apt-get install openjdk-8-jdk-headless

Install OpenJDK 8 Java Runtime Environment (JRE)

To install OpenJDK 8 JRE package we can use the command below.

sudo apt-get install openjdk-8-jre

To install OpenJDK 8 JRE Headless package we can use the command below.

sudo apt-get install openjdk-8-jre-headless

Summary

In this tutorial we learn how to setup Java OpenJDK 8 on Ubuntu 18.04. Firstly, we install Java Development Kit (JDK) packages both headless and non-headless.Secondly, We install Java Runtime Environment (JRE) packages both headless and non-headless.

References

In this section you can find several references to learn more about Java 8.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.