How-To'sLatest updates[ 288 items ]
How To Install Java runtime with command line on Ubuntu 18.04
Mar 12.2021Linux written by Razvan Iancu
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
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.
2. Install JDKYou 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.