Tutorials

How to Fix “Unable to Locate Package openjdk-8-jdk” in Ubuntu Server

By default, Ubuntu Server does not come with OpenJDK installed. OpenJDK must be installed manually from the repository.

However, sometimes even after running “sudo apt-get update”, the OpenJDK package is not found on the repository, even though it should be available for installation. The installation will fail with the following error:

user@computer:~/Java$ sudo apt-get install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package openjdk-8-jdk

How to Fix “unable to locate package openjdk-8-jdk” Error

If such an error happened to your Ubuntu Server installation, do not worry! You do not need to rebuild the server installation from scratch; you can install OpenJDK from another repository such as the Debian Jessie repository.

Sponsored

The installation from another sanctioned repository, like the Debian one, will not break your existing installation and repository setup. In fact, OpenJDK 8 from the official Debian repository is 100 percent compatible with Ubuntu Server since Ubuntu Server is based on Debian. If you use Ubuntu 16.04, follow these steps to get started.

First, you need to install the Debian Archive keyring package by issuing the following command:

sudo apt-get install debian-keyring debian-archive-keyring

Then, issue the following command (you can replace nano with vim or other text editors you like)

sudo nano /etc/apt/sources.list.d/debian-jessie-backports.list

In the text file, enter the following string:

Sponsored
deb http://httpredir.debian.org/debian/ jessie-backports main

Then, save the text file and quit nano. Afterward, you need to create another text file using this command:

sudo nano /etc/apt/preferences.d/debian-jessie-backports

Paste this string into the new text file:

Package: *
Pin: release o=Debian,a=jessie-backports
Pin-Priority: -200

Afterward, save the text file and quit Nano. Enter the following command to upgrade the package database:

sudo apt-get update

And finally, issue the following command to install OpenJDK from the Debian Jessie repository:

sudo apt-get -t jessie-backports install openjdk-8-jdk
Ubuntu Server Admin

Recent Posts

From sales development to renewals: Mariam Tawakol’s career progression at Canonical

Career progression doesn’t follow a single path – and at Canonical, we embrace that. Our…

9 hours ago

In pursuit of quality: UX for documentation authors

Canonical’s Platform Engineering team has been hard at work crafting documentation in Rockcraft and Charmcraft…

9 hours ago

Ubuntu 24.10 (Oracular Oriole) reached End of Life on 10th July 2025

This is a follow-up to the End of Life warning sent earlier to confirm that…

1 day ago

Canonical announces Charmed Feast: A production-grade feature store for your open source MLOps stack

July 10, 2025: Today, Canonical announced the release of Charmed Feast, an enterprise solution for…

1 day ago

Ubuntu Adding NVIDIA 575 Driver Support for 24.04 & 22.04 LTS

For NVIDIA users, the latest 575 series driver will be available soon in Ubuntu repository.…

2 days ago

Amarok Released 3.3 with Qt6/KF6 Port & GStreamer Backend

Amarok, the free open-source KDE music player, released new 3.3 version on Tuesday, named “Far…

2 days ago