Fix: unable to locate package openjdk 8 jdk

JDK stands for Java Development Kit, utilized to build an environment for Java programs. It offers various versions, and the appropriate JDK version is required to run a specific Java application. OpenJDK 8 package assists different utilities to Java users, such as building and deploying Java applications. During the installation of this package, an error “unable to locate package openjdk-jdk” comes across. This guide will provide the reasons and multiple solutions to tackle this error:

Reason: Package Unavailable in Repository

By default, the OpenJDK 8 does not include in the Ubuntu repository. It may be one of the main reasons that cause this error. It can be observed that the OpenJDK-8 is not in the default repo of Ubuntu:

Solution: Install OpenJDK via PPA Repository

The OpenJDK 8 installation can be carried out by adding the PPA repository and installing the version from that. First, add the PPA repository using the command:

$ sudo add-apt-repository ppa:webupd8team/java

After executing the script, it requires permission to install packages. Hit the “ENTER” to continue the installation process:

Update Repository

The below script will update the system packages to load updated packages on the system repository:

$ sudo apt update

Install OpenJDK-8-jdk Package

For installing the OpenJDK-8-JDK package, run the script as root privilege:

$ sudo apt install openjdk-8-jdk

Reason 2: Core Libraries/System Packages are not Updated 

The OpenJDK 8 version is available through the PPA repository. After adding the PPA repository, if the system’s packages (core libraries) are not updated, the system will be unable to install the required version, i.e., OpenJDK-8.

Solution: Update the Core Libraries

After adding the PPA, you must ensure that system packages are up to date. To do so, the following command is used:

$ sudo apt update

After doing so, now install the package via the following command, and the error will be removed.

$ sudo apt install openjdk-8-jdk

That is all from this guide.

Conclusion

The error “unable to locate package openjdk 8 jdk” occurs if the OpenJDK-8 is installed without adding PPA. To solve this, add the appropriate PPA repository and update the system followed by the command “sudo apt install openjdk-8-jdk”. Another reason may be the system’s packages are not up to date. To counter that, use the “sudo apt update” command after adding PPA. This post has addressed the possible reasons and the solutions to solve the above-stated error.

500M+ Views on Our Blogs & YouTube Channels till Now. We are helping 10 Businesses join our Agency and become a part of our growth. Click here if you are interested. ×