How to Install Java on Ubuntu 20.04 - MS TV Life.COM

How to Install Java on Ubuntu 20.04

How to Install Java on Ubuntu 20.04

We hope this post helped you to find out  How to Install Java on Ubuntu 20.04

On this information, we are going to describe the best way to set up Java on Ubuntu 20.04.

Java is likely one of the hottest programming languages used to construct completely different sorts of functions and methods. Java runs on all main working methods and gadgets. You will discover functions developed in Java in your laptop computer, cellphone, and recreation console.

Step 1 Earlier than You Start #

There are a number of completely different implementations of Java. OpenJDK and Oracle Java are the 2 major implementations of Java, with nearly no variations between them besides that Oracle Java has a couple of extra business options. Oracle Java License permits solely non-commercial use of the software program, corresponding to private use and improvement use.

The default Ubuntu 20.04 repositories embody two OpenJDK packages, Java Runtime Surroundings (JRE) and Java Growth Equipment (JDK). The JRE consists of the Java digital machine (JVM), lessons, and binaries that can help you run Java applications. The JDK consists of the JRE and improvement/debugging instruments and libraries needed to construct Java functions.

If you’re undecided which Java package deal to put in, the final advice is to put in to the default OpenJDK (JDK 11) model. Some Java-based functions could require a selected model of Java, so you must seek the advice of the applying documentation.

Step 2 Installing OpenJDK 11 #

On the time of writing, Java 11 is the most recent long-term supported (LTS) model of Java. It’s also the default Java improvement and runtime in Ubuntu 20.04.

Run the next instructions as a user with sudo privileges or root to replace the packages index and set up the OpenJDK 11 JDK package deal:

sudo apt update
sudo apt install openjdk-11-jdk

As soon as the set up is full, you’ll be able to confirm it by checking the Java model:

java -version

The output should look something like this:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

That’s it! At this level, you could have efficiently put in Java in your Ubuntu system.

JRE is included within the JDK package deal. When you want solely JRE, set up the openjdk-11-jre package deal. For minimal Java runtime, set up the openjdk-11-jdk-headless package deal.

Step 3 Putting in OpenJDK 8 #

Java 8, the earlier Java LTS model, remains to be broadly used. In case your utility runs on Java 8, you’ll be able to set up it by typing the next instructions:

sudo apt update
sudo apt install openjdk-8-jdk

Verify the installation by checking the Java version:

java -version

The output should look something like this:

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 4 Setting the Default Version #

You probably have a number of Java variations put in in your Ubuntu system you’ll be able to examine which model is ready because the default one by typing:

java -version

To change the default version, use the update-alternatives command:

sudo update-alternatives --config java

The output will look something like below:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 

You will be presented with a list of all installed Java versions. Enter the number of the version you want to be used as the default and press Enter.

Stop 5 JAVA_HOME Environment Variable #

The JAVA_HOME environment variable is used by some Java applications to determine the Java installation location.

To set the JAVA_HOME variable, first find the Java installation path with update-alternatives:

sudo update-alternatives --config java

In this example, the installation paths are as follows:

  • OpenJDK 11 is located at /usr/lib/jvm/java-11-openjdk-amd64/bin/java
  • OpenJDK 8 is located at /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Once you found the path of your preferred Java installation, open the /etc/environment file:

sudo nano /etc/environment

Assuming you want to set JAVA_HOME to point to OpenJDK 11, add the following line, at the end of the file:


For modifications to take impact in your present shell you’ll be able to both log off and log in or run the next source command:

source /etc/environment

Verify that the JAVA_HOME environment variable was correctly set:


You should see the path to the Java installation:


/etc/environment is a system-wide configuration file, which is used by all users. If you want to set the JAVA_HOME variable on a per-user basis, then add the line to the .bashrc or any other configuration file which is loaded when the user logs in.

Step 6 Uninstalling Java #

You can uninstall Java like any other package installed with apt.

For example, to uninstall the default-jdk package enter:

sudo apt remove openjdk-11-jdk

Conclusion #

OpenJDK 11 and OpenJDK Eight can be found within the default Ubuntu 20.04 repositories and may be put in utilizing the apt package deal supervisor.

We hope the How to Install Java on Ubuntu 20.04 help you. If you have any query regarding How to Install Java on Ubuntu 20.04drop a comment below and we will get back to you at the earliest.

We hope this post helped you to find out  How to Install Java on Ubuntu 20.04  . You may also want to see – How to Install Anaconda on CentOS 8

Copy link
Powered by Social Snap