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
sudoprivileges.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 upgradeCheck 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 fromDownloadsfolder 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 updateInstall the oracle JDK.
sudo apt install oracle-java11-installer-localIf you want Oracle JDK as the system default, install
oracle-java11-set-default-local:sudo apt install oracle-java11-set-default-localCheck that the install was successful with the following command:
java --versionroot@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/profileor log out of your system and back in to set the Java environment variables:source /etc/profileroot@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-jdkInstall 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.