linux commands

How to install OpenJDK 11 in Ubuntu Machine ?

This tutorial guides you on how to install JDK 11 in ubuntu machine i.e., install OpenJDK 11 from Oracle in Ubuntu from the command line.

Install OpenJDK 11 in Ubuntu – Package

To install OpenJDK via packages in Ubuntu machine, you need to execute the following command from command line.

$ sudo apt-get install openjdk-11-jdk

After installation, you can check the installation and Java version that is actually installed using the following command.

$ java -version
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-post-Debian-1deb10u2)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-post-Debian-1deb10u2, mixed mode, sharing)

Installing OpenJDK 11 in Ubuntu – Manually

To install OpenJDK in Ubuntu manually, you need to download the tar ball and extract it somewhere as shown below.

First, you need to download the required OpenJDK version from the OpenJDK Archive

For example, you can download locally using wget command as shown below.

$ wget https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz
--2021-01-18 14:32:26--  https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz
Resolving download.java.net (download.java.net)... 23.40.36.87
Connecting to download.java.net (download.java.net)|23.40.36.87|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 187599951 (179M) [application/x-gzip]
Saving to: ‘openjdk-11.0.1_linux-x64_bin.tar.gz’

openjdk-11.0.1_linux-x64_bin.tar.gz     100%[=============================================================================>] 178.91M  5.50MB/s    in 31s 

2021-01-18 14:32:58 (5.72 MB/s) - ‘openjdk-11.0.1_linux-x64_bin.tar.gz’ saved [187599951/187599951]

sneppets@cloudshell:~ (poised-shift-300712)$ ls
openjdk-11.0.1_linux-x64_bin.tar.gz  testdir

Then you need to extract the downloaded OpenJDK tar.gz file to Java’s default location as shown below.

$ sudo tar xfvz openjdk-11.0.1_linux-x64_bin.tar.gz --directory /usr/lib/jvm

Once the extraction is done, you can remove the tar.gz file if you would like by running the following command.

$ rm -f openjdk-11.0.1_linux-x64_bin.tar.gz

That’s it. you have learnt how to install OpenJDK 11 in ubuntu machine using packages and by manually.

Hope it helped 🙂

References

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments