How to Remove & Install Oracle Java JDK in Ubuntu 16.0.4

Post Date: December 7, 2019
Last Updated: November 03, 2026

Introduction

This guide shows you how to install Oracle Java JDK in Ubuntu 16.0.4 (Ubuntu 16.04 LTS Xenial) after removing the older Oracle JDK 8. Java powers web applications, software development, and Android development, so a clean JDK and JRE setup is often the first task on a new server.

You will purge Oracle Java 8, add the Java PPA, install Oracle Java 11 LTS, and verify the version.

Note: Ubuntu 16.04 has passed its standard support period, so it no longer receives regular updates. Oracle has also tightened its download rules, so the installer package used below may fail to fetch the Java archive. A manual fallback is in the Troubleshooting section. For new servers, use a currently supported Ubuntu LTS release.

Prerequisites

Before you install Oracle Java JDK in Ubuntu 16.0.4, make sure you have:

  • A server or desktop running Ubuntu 16.04 LTS with sudo access
  • An active internet connection
  • A backup or snapshot of the server, so you can roll back if an application depends on the old Java version

Architecture

  • dpkg and apt: These list, remove, and install the Java packages.
  • PPA ppa:linuxuprising/java: This extra repository provides the oracle-java11-installer package.
  • Installer script: It downloads the Java archive from Oracle’s site and configures it on your system.
  • oracle-java11-set-default: This package makes Java 11 the default version.
  • Where problems happen: Most failures occur at the download step or when an old Java version stays as the default.

The image below shows the installation flow of Oracle Java JDK in Ubuntu 16.0.4:

For more details, see the official Oracle JDK 11 documentation.

Steps to Install Oracle Java JDK in Ubuntu 16.0.4

The JDK compiles Java source files into class files, and the JRE runs those class files. Run the commands below one by one.

1. Check which JDK packages are installed

sudo dpkg --list | grep -i jdk

2. Purge Oracle Java 8

sudo apt-get purge oracle-java8-installer
sudo apt-get autoremove

Run the check from step 1 again. If nothing is listed, all JDK packages are gone. You can also remove the old PPA if you no longer need it.

Terminal showing old Oracle Java JDK packages removed in Ubuntu 16.0.4

3. Update the installed packages

sudo apt update
sudo apt upgrade

4. Add the Java PPA

sudo add-apt-repository ppa:linuxuprising/java

5. Install Java 11

sudo apt update
sudo apt-get install oracle-java11-installer

Accept the license agreement when the installer prompts you.

License prompt while installing Oracle Java JDK in Ubuntu 16.0.4

6. Set Java 11 as the default

sudo apt-get install oracle-java11-set-default

7. Verify the Java version

java -version

Expected output:

java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

Java 11 version output after installing Oracle Java JDK in Ubuntu 16.0.4

Note: The original post said “Ubuntu 16.0.4” and had an empty bullet before the PPA step. The correct release name is Ubuntu 16.04, and the steps are now numbered 1 to 7 so each command is easy to follow. The URL and keyphrase keep “16.0.4” only to match the existing permalink.

Troubleshooting

If Oracle Java JDK in Ubuntu 16.0.4 still doesn’t work, check these:

  • Installer can’t download the archive: Oracle now restricts some downloads. Download the JDK .tar.gz manually from the Oracle Java downloads page, extract it to /usr/lib/jvm, and register it with update-alternatives.
  • Old version still showing: Run sudo update-alternatives --config java and select Java 11.
  • PPA not found or errors on update: The PPA may have changed or been withdrawn. Remove it with sudo add-apt-repository --remove ppa:linuxuprising/java and use the manual method.
  • Command not found: Run which java and confirm that /usr/bin/java points to the new JDK.

Conclusion

You have removed the old Oracle JDK 8 and installed Java 11 LTS on Ubuntu 16.04. Verify with java -version after every install, and plan an upgrade to a supported Ubuntu release soon.

Frequently Asked Questions

How do I remove Oracle Java JDK in Ubuntu 16.0.4?
Run sudo apt-get purge oracle-java8-installer, then sudo apt-get autoremove. Confirm with sudo dpkg --list | grep -i jdk.

Which Oracle Java JDK version can I install in Ubuntu 16.0.4?
This guide installs Oracle Java 11 LTS using the oracle-java11-installer package from the linuxuprising PPA.

How do I check that Oracle Java JDK in Ubuntu 16.0.4 installed correctly?
Run java -version. It should show version 11 along with the Java SE Runtime Environment details.

Why does the Oracle Java JDK installer fail in Ubuntu 16.0.4?
Oracle changed its download rules, so the script may not fetch the archive. Use the manual .tar.gz method in the Troubleshooting section.

JavaScript Cookies: How to Set, Get, and Delete Cookies

Generate PDF using JavaScript

Talk to Our Technology Experts

Need help setting up Java environments or managing your Ubuntu servers? Our team can install and configure your runtimes, handle upgrades, and keep your servers running smoothly with our DevOps and Cloud Services.

Connect with our technology experts.

admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Comment

Scroll to Top