This article guides you with Oracle JRE and JDK installation on Ubuntu 18.04 operating system.
Check if Java is already on the system
$ java -v
Update Repositories
Update the repositories using the command below.
$ sudo apt update
Install Oracle JRE (Java Run-time Environment)
Run the following command to install the default version of JRE.
$ sudo apt install -y default-jre
Verify JRE installation
Verify the version of JRE installed using the following command.
$ java -version
Install Oracle JDK
Run the following command to install the default version of JDK..
$ sudo apt install default-jdk
Verify JDK installation
Verify the version of JRE installed using the following command. Please note that “javac” is the java compiler, and it is not part of the JRE package. The javac comes with the JDK package.
$ javac -version