Install OpenJDK 11 on Ubuntu 18.04 LTS

Carvia Tech | November 23, 2019 | 2 min read | 90 views

We will learn how to install openjdk-11 on ubuntu 18.04 LTS, setting the default java version and setting up java home.

Install OpenJDK-11

The below command will install OpenJDK (Java Development Kit) version 11 on your Debian based system (Ubuntu 18)

Install OpenJDK 11
$ sudo apt-get install openjdk-11-jdk

Configure default Java version

Once we have installed java, we can use below command to verify the version.

Check java version
$ java -version

java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)

In order to list all the JDK installs available on your system, run the below command:

List all java installs
$ update-java-alternatives -l

java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64
java-8-oracle                  1081       /usr/lib/jvm/java-8-oracle

Changing the default JDK is easy using update-alternatives utility in Ubuntu.

Change the default version
$ sudo update-alternatives --config java


We shall setup JAVA_HOME environment variable to appropriate java version so that other tools and libraries for example Gradle picks up the proper version.

On Ubuntu, we shall use /etc/environment to set the JAVA_HOME

$ sudo vi /etc/environment

Add the below line towards the end of this file


Source the newly set JAVA_HOME

source /etc/environment

Check the JAVA_HOME

$ echo $JAVA_HOME


That’s all for now.

Top articles in this category:
  1. DevOps interview questions - Basic Concepts, Microservices, Databases, AWS
  2. Install and upgrade Jenkins on Ubuntu 18.04 LTS
  3. Upgrade MySQL from 5.7 to 8 on Ubuntu 18.04
  4. Installing nginx on macOS Mojave using brew
  5. Install Artifactory OSS private maven repository
  6. Basic Unix commands for every programmer
  7. Difference between Forward Proxy and Reverse Proxy Server

Find more on this topic:
Dev Ops image
Dev Ops

Dev Ops Automation - Ubuntu OS, Centos, MySql, MongoDB, Java, AWS Infrastructure.

Last updated 1 week ago

Recommended books for interview preparation:

This website uses cookies to ensure you get the best experience on our website. more info