Install OpenJDK 11 on Ubuntu 18.04 LTS

Carvia Tech | November 23, 2019 | 2 min read | 786 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

Set JAVA_HOME

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

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/"

Source the newly set JAVA_HOME

source /etc/environment

Check the JAVA_HOME

$ echo $JAVA_HOME

/usr/lib/jvm/java-11-openjdk-amd64/

That’s all for now.


Top articles in this category:
  1. Upgrade Jenkins on Ubuntu 18.04 LTS
  2. Install ElasticSearch 7 on Ubuntu 20.04
  3. Install Cassandra 4 on Ubuntu 20.04
  4. Install & configure Redis on Ubuntu
  5. Upgrade MySQL from 5.7 to 8 on Ubuntu 18.04
  6. Install Erlang 23 and Rabbitmq on Ubuntu 20
  7. MySql 8 installation on Ubuntu 20

Find more on this topic:

Recommended books for interview preparation:

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