How To Install Java on Ubuntu 20.04

Windows Articles

How to increase privacy in Windows 10.

Hello! Without a doubt the time of use of electronic devices has increased lately. Indeed, with the limitations imposed by the COVID-19...

How to install Java 15 on OpenSUSE 15.2?

Recently Java 15 has been released with interesting new features in the accounting field and introducing many security patches. In spite of...

How to install Redis on CentOS 8?

Hello, friends in this post, we will show you how to install Redis on CentOS 8 As we well...

How to enable and disable startup applications in Windows 10

Hello! Windows 10 is an attractive and very easy to use system. However, some criticism has come for being too "heavy". That...

How to install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...

Today we are going to learn that how to install Java on Ubuntu 20.04. Before going to the Java installation let’s have a short introduction about it. Java is the most popular and interesting language used for programming, gaming and developing different tools. Most developers prefer Java to build Java based applications. Just follow the below steps for an easy installation.

Step 1: Update Your System

As it is a good practice to update your system before going to install any new package so update the system.

sudo apt update

Step 2: Install Java OpenJDK JDK on Ubuntu 20.04

To install the Java OpenJDK on your Ubuntu 20.04 system type the below command in your terminal.

For Java 11 run the following command. And press Y when prompted.

sudo apt install openjdk-11-jdk

Output:

You’ll see the similar output upon successful installation.

Processing triggers for gnome-menus (3.36.0-1ubuntu1) …
Processing triggers for man-db (2.9.1-1) …
Processing triggers for ca-certificates (20190110ubuntu1) …
Updating certificates in /etc/ssl/certs…
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d…
done.
done.
Processing triggers for sgml-base (1.29.1) …
Setting up x11proto-dev (2019.2-1ubuntu1) …
Setting up libxau-dev:amd64 (1:1.0.9-0ubuntu1) …
Setting up libice-dev:amd64 (2:1.0.10-0ubuntu1) …
Setting up libsm-dev:amd64 (2:1.2.3-1) …
Setting up libxdmcp-dev:amd64 (1:1.1.3-0ubuntu1) …
Setting up x11proto-core-dev (2019.2-1ubuntu1) …
Setting up libxcb1-dev:amd64 (1.14-2) …
Setting up libx11-dev:amd64 (2:1.6.9-2ubuntu1) …
Setting up libxt-dev:amd64 (1:1.1.5-1) …

For Java 8 run the given command.

sudo apt install -y openjdk-8-jdk

Output:

Upon successful installation you’ll see the similar output.

provide /usr/bin/idlj (idlj) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/wsimpo
rt to provide /usr/bin/wsimport (wsimport) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jsadeb
ugd to provide /usr/bin/jsadebugd (jsadebugd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/native
2ascii to provide /usr/bin/native2ascii (native2ascii) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javah
to provide /usr/bin/javah (javah) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/clhsdb
to provide /usr/bin/clhsdb (clhsdb) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/extche
ck to provide /usr/bin/extcheck (extcheck) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/hsdb t
o provide /usr/bin/hsdb (hsdb) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/schema
gen to provide /usr/bin/schemagen (schemagen) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/xjc to
provide /usr/bin/xjc (xjc) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jhat t
o provide /usr/bin/jhat (jhat) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/wsgen
to provide /usr/bin/wsgen (wsgen) in auto mode
Setting up openjdk-8-jdk:amd64 (8u252-b09-1ubuntu1) …
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/applet
viewer to provide /usr/bin/appletviewer (appletviewer) in auto mode
Processing triggers for mime-support (3.64ubuntu1) …
Processing triggers for hicolor-icon-theme (0.17-2) …
Processing triggers for gnome-menus (3.36.0-1ubuntu1) …
Processing triggers for libc-bin (2.31-0ubuntu9) …
Processing triggers for desktop-file-utils (0.24-1ubuntu2) …

Step 3: Install Java OpenJDK JDK Headless

To install JDK headless simply fire the below command in your terminal.

For Java Headless 11 JDK.

sudo apt install -y openjdk-11-jdk-headless

For Java Headless 8 JDK.

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

Step 4: Install Java OpenJDK JRE on Ubuntu 20.04

Hit the command given below in your terminal.

For Java JRE 11.

sudo apt install -y openjdk-11-jre

Java JRE 8.

sudo apt install -y openjdk-8-jre

For Java JRE headless

You can install Java JRE headless with the help of following command.

For Java 11.

sudo apt install -y openjdk-11-jre-headless

For Java 8.

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

Step 5: How To Set Default Java Version on Ubuntu 20.04

Run the below command to set the default java version on Ubuntu 20.04.

sudo update-alternatives --config java

Select the number from the list you want to make default java version.

How To Install Java on Ubuntu 20.04

Verify the installed Java version by running the below command.

java -version

Output:

sabi@Ubuntu:~$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Step 6: Setting Up Environment Variables

For setting up environment variables you’ve to create a new file. To do this run the following command.

sudo nano /etc/profile.d/java.sh

And then provides the variables paths where the Java is installed.

export PATH=$PATH:/usr/lib/jvm/java-11-openjdk-amd64/bin/
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
export J2SDKDIR=/usr/lib/jvm/java-11-openjdk-amd64/

And finally source the file.

source /etc/profile.d/java.sh

That’s it you’ve successfully installed Java.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to increase privacy in Windows 10.

Hello! Without a doubt the time of use of electronic devices has increased lately. Indeed, with the limitations imposed by the COVID-19...

How to install Java 15 on OpenSUSE 15.2?

Recently Java 15 has been released with interesting new features in the accounting field and introducing many security patches. In spite of...

How to install Redis on CentOS 8?

Hello, friends in this post, we will show you how to install Redis on CentOS 8 As we well...

How to enable and disable startup applications in Windows 10

Hello! Windows 10 is an attractive and very easy to use system. However, some criticism has come for being too "heavy". That...

How to install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...
x