СHRISTMAS
WHEEL OF FORTUNE

Tap the button and win a guaranteed prize right now!

By registering, you are signing up to receiving e-mails.
MA
July 13 2020
Updated June 7 2023

How To Install Java with apt on Ubuntu 18.04

Ubuntu

Java and JVM (Java Virtual Machine) are required for many types of software, including Tomcat, Jetty, Glassfish, Cassandra and Jenkins.

This guide will help you learn how to install different versions of the Java Runtime Environment (JRE) and Java Developer Kit (JDK) with apt.

How to install Java with apt on Ubuntu 18.04:

Java Runtime Environment

The easiest way to install Java is to use the version included in the Ubuntu package. By default, Ubuntu 18.04 includes Open JDK (open source JRE and JDK version).

This package installs OpenJDK version 10 or 11.

  • Until September 2018, OpenJDK 10 was installed.
  • After September 2018, OpenJDK 11 is installed.

First, update the package lists:

sudo apt update

How To Install Java with apt on Ubuntu 18.04

Then you need to check if Java is already installed:

java -version

If Java was newer installed, yo’ll see the following results:

If Java was newer installed, yo’ll see the following results

Run the following command to install OpenJDK:

sudo apt install default-jre

Run the following command to install OpenJDK

Type y (yes) and press Enter to resume installation.

This command installs the Java Runtime Environment (JRE). It allows you to run almost any Java software.

Now check the Java version:

java -version

Now check the Java version

JRE is installed!

Java Development Kit

To compile and run some specific Java programs in addition to the JRE, you may need the Java Development Kit (JDK). To install the JDK, run the following command, which also installs the JRE:

sudo apt install default-jdk

To install the JDK, run the following command

Type y (yes) and press Enter to resume installation.

This command installs the Java Development Kit (JDK).

Now check JDK version with command:

javac -version

Now check JDK version with command

JDK is installed!

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.