Install Oracle Java SE Development Kit 11 on Ubuntu

Updated by Linode Contributed by Phil Zona

Contribute on GitHub

Report an Issue | View File | Edit File

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.

  • Update your system:

    sudo apt update && sudo apt upgrade

Install Oracle JDK

The Linux Uprising Oracle Java PPA uses packages that include install scripts to download and install the Oracle JDK from Oracle’s website. Alternatively, you can manually download the binaries.

  1. Add the PPA to Ubuntu. Apt will automatically refresh the package cache.

    sudo add-apt-repository ppa:linuxuprising/java
  2. Install the JDK. You’ll be asked to agree to the licensing terms.

    sudo apt install oracle-java11-installer
  3. If you want Oracle JDK as the system default, install oracle-java11-set-default:

    sudo apt install oracle-java11-set-default
  4. Check that the install was successful with the following command:

    java --version
    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)
  5. 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

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.

comments powered by Disqus

This guide is published under a CC BY-ND 4.0 license.