WindowsMacLinuxAndroid APKGames
How-To'sLinuxHow To Install Java runtime with command line on Ubuntu 18.04

How To Install Java runtime with command line on Ubuntu 18.04

Mar 12.2021Linux written by Razvan Iancu
banner How To Install Java runtime with command line on Ubuntu 18.04
In this guide, we show you how to install different versions of Java Runtime Environment (JRE) and Java Developer Kit (JDK) using Ubuntu 18.04.5 LTS (Bionic Beaver) terminal.

You will install OpenJDK along with the official Oracle packages. Then you will select the version you want to use for your projects.

Once youre done, you can use JDK to develop software, or you can use Java Runtime to run the software.

1. Install JRE

How To Install Java runtime with command line on Ubuntu 18.04 - screenshot 01

The easiest option to install Java is to use the version that comes with Ubuntu. By default, Ubuntu 18.04 includes Open JDK, which is an open source version of JRE and JDK.

$ sudo apt update
Then check if Java is already installed

$ java -version
If Java is not installed follow the command. This command will install the Java Runtime Environment (JRE). This will allow you to run almost any Java software.

$ sudo apt install default-jre
Check the installation with the command again.

java -version

2. Install JDK

You may need the Java Development Kit (JDK) in addition to the JRE to compile and run specific Java-based software. To install JDK, run the following command, which will also install JRE.

$ sudo apt install default-jdk
Verify that the JDK is installed by checking the Java compiler version.

javac -version