Unable to Locate Package openjdk 8 jre

·

3 min read

In the course of our work, we will not always be able to complete everything correctly. The difference between a computer and a human being is that a human can forget when performing a task repeatedly, increasing the chances of error, but a computer can execute the same activity again in the best possible manner without making a mistake. Our Platform Kodlogs gives mistake solutions that are simple for newbies to understand, as well as assistance for those who have forgotten things for various reasons.

In this blog article, we'll look at the error message "Unable to locate package openjdk 8 jre" that arises during OpenJDK installation on Linux(Ubuntu), explain what it means, why it happens, and how to fix it.

Image description

What is Unable to Locate Package openjdk 8 jre

Ubuntu Server does not include OpenJDK by default, which implies that when you install Ubuntu Server, it will not include OpenJDK. You must manually install JDK if you wish to utilise it. During the installation, this error might be noticed. Along with the installation failure notice, this message will be displayed.

By the way, this is a typical error message, and any such message must disturb the user.

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

Why This Message will Appear

However, even after executing

sudo apt-get update

Even though it should be, the OpenJDK package is not always found in the repository. It's just due to a compatibility issue. It will function great if you obtain the suitable OpenJDK from the official repository.

The Solution

Do not be afraid if this error happened during the Ubuntu Server installation! You do not need to reinstall the server; OpenJDK may be installed from a different repository, such as the Debian Jessie repository.

If you install from another sanctioned repository, such as the Debian one, your existing installation and repository setup will not be harmed. In truth, because Ubuntu Server is based on Debian, OpenJDK 8 from Debian's official repository is fully compatible with Ubuntu Server. Follow these steps to get started with Ubuntu 16.04.

To begin, use the following command to install the Debian Archive keyring package:

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

Then run the command that follows (you can replace nano with vim or other text editors you like)

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

Put the following string in the text file:

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

After that, leave nano and save the text file. After that, use the following command to create a new text file:

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

Copy and paste the following string into the new text file:

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

Save the text file and exit Nano after that. To upgrade the package database, use the following command:

sudo apt-get update

Finally, to install OpenJDK from the Debian Jessie repository, use the following command:

sudo apt-get -t jessie-backports install openjdk-8-jdk

The Conclusion

What a wonderful world it would be if we could live in a place where we could interact with nature without making mistakes or encountering difficulties. However, the consequences of such an environment would be too great; we would lose our ability to think and understand, and we would become a species of animals with little variation. It's awful to believe that.