Install Oracle Java SE Development Kit 11 on Ubuntu
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
Update your system:
sudo apt update && sudo apt upgrade
Install Oracle JDK
Add the PPA to Ubuntu. Apt will automatically refresh the package cache.
sudo add-apt-repository ppa:linuxuprising/java
Install the JDK. You’ll be asked to agree to the licensing terms.
sudo apt install oracle-java11-installer
If you want Oracle JDK as the system default, install
sudo apt install oracle-java11-set-default
Check that the install was successful with the following command:
root@ubuntu:~# java --version java version "11.0.2" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.2+7-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+7-LTS, mixed mode)
/etc/profileor log out of your system and back in to set the Java environment variables:
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
This guide is published under a CC BY-ND 4.0 license.