Oracle Java 11 is a Long-Term Support (LTS) version widely used for enterprise applications, web servers, and development environments. Unlike OpenJDK, Oracle Java comes with commercial support and additional features.
This guide will show you step-by-step how to install Oracle Java 11 on Ubuntu 18.04.4 LTS.
Open the terminal and type these command in the terminal.
Step 1: Create a Local Installer Directory
Oracle Java installer requires a local cache directory. Run:
sudo mkdir -p /var/cache/oracle-jdk11-installer-local/
This creates a folder where the installer will look for the downloaded .tar.gz file.
Step 2: Move the Downloaded JDK File
Navigate to the folder where you downloaded the Oracle JDK 11 .tar.gz file:
cd ~/Downloads
Then copy the file to the local installer directory:
sudo cp jdk-11.0.6_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
Step 3: Remove Previous Oracle Java 11 (Optional)
If you have a previously installed Oracle Java 11, remove it first:
sudo apt purge oracle-java11-installer
This ensures a clean installation.
Step 4: Add the Linux Uprising PPA
Add the Linux Uprising PPA to get the Oracle Java installer:
sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
Step 5: Install Oracle Java 11
Install the local Oracle Java 11 installer:
sudo apt install oracle-java11-installer-local
Step 6: Set Oracle Java 11 as Default
To set Java 11 as the default version for your system, run:
sudo apt install oracle-java11-set-default-local