Installing Oracle Java SE Development Kit 11 on Ubuntu 18.04
Updated by Linode Contributed by Phil Zona
Java is one of the world’s most popular programming languages and can be used to create anything from software to basic web applications. Java was originally developed at Sun Microsystems, which was bought by Oracle. For this reason, Oracle’s Java platform is the most well known. However, there are other such as IBM Runtimes, Red Hat’s Open JDK, and Zulu.
With the release of version 11, Oracle has updated the JDK license to be significantly different from previous versions. Oracle JDK is now a paid commercial license, but free for development use.
Oracle’s OpenJDK is GPL licensed. With the exception of cosmetic and packaging differences, the OpenJDK and Java SE (Standard Edition) development kits are identical. See Oracle’s Java download page and license to further decide which version is appropriate for you.
This guide demonstrates installing Oracle’s Java Standard Edition Development Kit (Oracle JDK) on Ubuntu 18.04. Installing OpenJDK is also explained for a free and open source alternative.
Before You Begin
You will need root access to your Linode, or a limited user account with
sudo
privileges.Connect to your Linode using a remote desktop sharing system such as a VNC. For more information, see Install VNC on Ubuntu 18.04 guide.
Create an Oracle account and download the Oracle JDK 11 .tar.gz archive. Ensure that the Oracle JDK version is the same as the oracle-java11-installer-local package version.
Install Oracle JDK
The Linux Uprising Oracle Java PPA uses packages that include install scripts to install the Oracle JDK.
Update your system:
sudo apt update && sudo apt upgrade
Check that SHA256 checksum of the binary you downloaded matches the checksum:
cd Downloads/ sha256sum jdk-11.0.5_linux-x64*
Create a
/var/cache/oracle-jdk11-installer-local/
folder, and copy the Oracle JDK 11 .tar.gz fromDownloads
folder to this folder.sudo mkdir -p /var/cache/oracle-jdk11-installer-local/ sudo cp jdk-11.0.5_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
Add the PPA to Ubuntu. Apt will automatically refresh the package cache.
sudo add-apt-repository ppa:linuxuprising/java sudo apt-get update
Install the oracle JDK.
sudo apt install oracle-java11-installer-local
If you want Oracle JDK as the system default, install
oracle-java11-set-default-local
:sudo apt install oracle-java11-set-default-local
Check that the install was successful with the following command:
java --version
root@ubuntu:~# java --version java version "11.0.5" 2019-10-15 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)
Reload
/etc/profile
or log out of your system and back in to set the Java environment variables:source /etc/profile
root@ubuntu:~# echo $JAVA_HOME /usr/lib/jvm/java-11-oracle
Install Oracle OpenJDK
OpenJDK includes a runtime environment and compiler which allows you to develop your own Java applications and run them on your Linode. If you only need to run Java applications which you’ve already downloaded, you can save some disk space by only installing the Java runtime environment. Both are available from Ubuntu’s repository.
Install OpenJDK 11:
sudo apt install openjdk-11-jdk
Install OpenJRE 11:
sudo apt install openjdk-11-jre
Join our Community
Find answers, ask questions, and help others.
This guide is published under a CC BY-ND 4.0 license.