apt can’t locate openjdk-16-jre-headless because the OpenJDK 16 packages aren’t available in any Debian release.
The only release available to you in Debian 10 is OpenJDK 11. Debian 11 has OpenJDK 17. Both of these are releases with long-term support.
Answer from Stephen Kitt on Stack Exchangeapt can’t locate openjdk-16-jre-headless because the OpenJDK 16 packages aren’t available in any Debian release.
The only release available to you in Debian 10 is OpenJDK 11. Debian 11 has OpenJDK 17. Both of these are releases with long-term support.
openjdk-16-jre-headless isn't packaged on Debian. You have to use openjdk-11-jre-headless, it can be installed after enabling the security repository.
Java and debian.
UPDATE: installation without root privileges below
I advise you to not install packages manually on ubuntu system if there is already a (semi-official) repository able to solve your problem. Further, use Oracle JDK for development, just to avoid (very sporadic) compatibility issues (i've tried many years ago, it's surely better now).
Add the webupd8 repo to your system:
Copysudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Install your preferred version of jdk (versions from java-6 to java-9 available):
Copysudo apt-get install oracle-java8-installer
You can also install multiple version of jdk, mixing openjdk and oracle versions. Then you can use the command update-java-alternatives to switch between installed version:
Copy# list available jdk
update-java-alternatives --list
# use jdk7
sudo update-java-alternatives --set java-7-oracle
# use jdk8
sudo update-java-alternatives --set java-8-oracle
Requirements
If you get add-apt-repository: command not found be sure to have software-properties-common installed:
Copysudo apt-get install software-properties-common
If you're using an older version Ubuntu:
Copysudo apt-get install python-software-properties
JDK installation without root privileges
If you haven't administrator rights on your target machine your simplest bet is to use sdkman to install the zulu certified openjdk:
Copycurl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java
NOTE: sdkman allow to install also the official Oracle JDK, although it's not a the default option. View available versions with:
Copysdk ls java
Install the chosen version with:
Copysdk install java <version>
For example:
Copysdk install java 9.0.1-oracle
Glossary of commands
sudo
<command> [command_arguments]: execute a command with the superuser privilege.add-apt-repository
<PPA_id>: Ubuntu (just like every Debian derivatives and generally speaking every Linux distribution) has a main repository of packages that handle things like package dependencies and updating. In Ubuntu is possible to extend the main repository using a PPA (Personal Package Archive) that usually contains packages not available in the system (just like oracle jdk) or updated versions of available ones (example: LibreOffice 5 in LTS is available only through this PPA).apt-get
[install|update|upgrade|purge|...]: it's "the" command-line package handler used to manipulate the state of every repository on the system (installing / updating / upgrading can be viewed as an alteration of the repository current state).
In our case: with the command sudo add-apt-repository ppa:webupd8team/java we inform the system that the next repository update must retrieve packages information also from webupd8 repo.
With sudo apt-get update we actually update the system repository (all this operations requires superuser privileges, so we prepend sudo to the commands).
sudo apt-get install oracle-java8-installer
update-java-alternatives (a specific java version of update-alternatives): in Ubuntu several packages provides the same functionality (browse the internet, compile mails, edit a text file or provides java/javac executables...). To allows the system to choose the user favourites tool given a specific task a mechanism using symlinks under
/etc/alternatives/is used. Try to update the jdk as indicated above (switch between java 7 and java 8) and view how change the output of this command:ls -l /etc/alternatives/java*
In our case: sudo update-java-alternatives --set java-8-oracle update symlinks under /etc/alternatives to point to java-8-oracle executables.
Extras:
man
<command>: start using man to read a really well written and detailed help on (almost) every shell command and its options (every command i mention in this little answer has a man page, tryman update-java-alternatives).apt-cache
search <search_key>: query the APT cache to search for a package related with the search_key provided (can be the package name or some word in package description).apt-cache
show <package>: provides APT information for a specific package (package version, installed or not, description).
As you can see I only have java 1.7 installed (on a Ubuntu 14.04 machine).
Copyupdate-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
To install Java 8, I did,
Copysudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
Afterwards, now I have java 7 and 8,
Copyupdate-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1069 /usr/lib/jvm/java-1.8.0-openjdk-amd64
BONUS ADDED (how to switch between different versions)
- run the follwing command from the terminal:
sudo update-alternatives --config javaCopyThere are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode 1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode * 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 manual mode Press enter to keep the current choice[*], or type selection number:
As you can see I'm running open jdk 8. To switch to to jdk 7, press 1 and hit the Enter key. Do the same for javac as well with, sudo update-alternatives --config javac.
Check versions to confirm the change: java -version and javac -version.
java - Unable to install the default jdk package on Debian - Stack Overflow
Cant install java on debian
java - Installing jdk8 on ubuntu- "unable to locate package" update doesn't fix - Stack Overflow
apt - Cannot install default-jre - package 'default-jre' has no installation candidate - Unix & Linux Stack Exchange
If i try to install using sudo apt-get install openjdk i get unable to locate package openjdk and if i try to add a repo i get the error in the photo so i cant install java using this repo i found in a tutorial
[17-08-2022] thank to @nobody (see comment to the question)
For all older version use this link:
https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt update
and select your version:
sudo apt install openjdk-15-jdk
It gives no openjdk-15-jdk in the repos from ubuntu :)
sudo apt list | grep openjdk [sudo] Passwort für k3ops: WARNING: apt does not have a stable CLI interface. Use with caution in scripts. openjdk-11-dbg/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 amd64 openjdk-11-dbg/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 i386 openjdk-11-demo/focal-updates 11.0.9.1+1-0ubuntu1~20.04 amd64 openjdk-11-demo/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 i386 openjdk-11-doc/focal-updates,focal-updates,focal-security,focal-security 11.0.9.1+1-0ubuntu1~20.04 all openjdk-11-jdk-headless/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 amd64 openjdk-11-jdk-headless/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 i386 openjdk-11-jdk/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 amd64 openjdk-11-jdk/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 i386 openjdk-11-jre-dcevm/focal 11.0.3+1-1 amd64 openjdk-11-jre-headless/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 amd64 openjdk-11-jre-headless/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 i386 openjdk-11-jre-zero/focal-updates 11.0.9.1+1-0ubuntu1~20.04 amd64 openjdk-11-jre-zero/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 i386 openjdk-11-jre/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 amd64 openjdk-11-jre/focal-updates,focal-security 11.0.9.1+1-0ubuntu1~20.04 i386 openjdk-11-source/focal-updates,focal-updates,focal-security,focal-security 11.0.9.1+1-0ubuntu1~20.04 all openjdk-13-dbg/focal-updates 13.0.4+8-1~20.04 amd64 openjdk-13-dbg/focal-updates 13.0.4+8-1~20.04 i386 openjdk-13-demo/focal-updates 13.0.4+8-1~20.04 amd64 openjdk-13-demo/focal-updates 13.0.4+8-1~20.04 i386 openjdk-13-doc/focal-updates,focal-updates 13.0.4+8-1~20.04 all openjdk-13-jdk-headless/focal-updates 13.0.4+8-1~20.04 amd64 openjdk-13-jdk-headless/focal-updates 13.0.4+8-1~20.04 i386 openjdk-13-jdk/focal-updates 13.0.4+8-1~20.04 amd64 openjdk-13-jdk/focal-updates 13.0.4+8-1~20.04 i386 openjdk-13-jre-headless/focal-updates 13.0.4+8-1~20.04 amd64 openjdk-13-jre-headless/focal-updates 13.0.4+8-1~20.04 i386 openjdk-13-jre-zero/focal-updates 13.0.4+8-1~20.04 amd64 openjdk-13-jre-zero/focal-updates 13.0.4+8-1~20.04 i386 openjdk-13-jre/focal-updates 13.0.4+8-1~20.04 amd64 openjdk-13-jre/focal-updates 13.0.4+8-1~20.04 i386 openjdk-13-source/focal-updates,focal-updates 13.0.4+8-1~20.04 all openjdk-14-dbg/focal-updates 14.0.2+12-1~20.04 amd64 openjdk-14-dbg/focal-updates 14.0.2+12-1~20.04 i386 openjdk-14-demo/focal-updates 14.0.2+12-1~20.04 amd64 openjdk-14-demo/focal-updates 14.0.2+12-1~20.04 i386 openjdk-14-doc/focal-updates,focal-updates 14.0.2+12-1~20.04 all openjdk-14-jdk-headless/focal-updates 14.0.2+12-1~20.04 amd64 openjdk-14-jdk-headless/focal-updates 14.0.2+12-1~20.04 i386 openjdk-14-jdk/focal-updates 14.0.2+12-1~20.04 amd64 openjdk-14-jdk/focal-updates 14.0.2+12-1~20.04 i386 openjdk-14-jre-headless/focal-updates 14.0.2+12-1~20.04 amd64 openjdk-14-jre-headless/focal-updates 14.0.2+12-1~20.04 i386 openjdk-14-jre-zero/focal-updates 14.0.2+12-1~20.04 amd64 openjdk-14-jre-zero/focal-updates 14.0.2+12-1~20.04 i386 openjdk-14-jre/focal-updates 14.0.2+12-1~20.04 amd64 openjdk-14-jre/focal-updates 14.0.2+12-1~20.04 i386 openjdk-14-source/focal-updates,focal-updates 14.0.2+12-1~20.04 all openjdk-8-dbg/focal-updates 8u275-b01-0ubuntu1~20.04 amd64 openjdk-8-dbg/focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 i386 openjdk-8-demo/focal-updates 8u275-b01-0ubuntu1~20.04 amd64 openjdk-8-demo/focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 i386 openjdk-8-doc/focal-updates,focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 all openjdk-8-jdk-headless/focal-updates 8u275-b01-0ubuntu1~20.04 amd64 openjdk-8-jdk-headless/focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 i386 openjdk-8-jdk/focal-updates 8u275-b01-0ubuntu1~20.04 amd64 openjdk-8-jdk/focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 i386 openjdk-8-jre-headless/focal-updates 8u275-b01-0ubuntu1~20.04 amd64 openjdk-8-jre-headless/focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 i386 openjdk-8-jre-zero/focal-updates 8u275-b01-0ubuntu1~20.04 amd64 openjdk-8-jre-zero/focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 i386 openjdk-8-jre/focal-updates 8u275-b01-0ubuntu1~20.04 amd64 openjdk-8-jre/focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 i386 openjdk-8-source/focal-updates,focal-updates,focal-security 8u275-b01-0ubuntu1~20.04 all uwsgi-plugin-jvm-openjdk-11/focal 2.0.18-11ubuntu1 amd64 uwsgi-plugin-jwsgi-openjdk-11/focal 2.0.18-11ubuntu1 amd64 uwsgi-plugin-ring-openjdk-11/focal 2.0.18-11ubuntu1 amd64 uwsgi-plugin-servlet-openjdk-11/focal 2.0.18-11ubuntu1 amd64
Ups better you use "apt search openjdk" for the correct command, the first is bad code :P
Command Line option - Ubuntu
Copysudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Then in terminal
Copysudo apt-get install oracle-java8-installer
When there are multiple Java installations on your System, the Java version to use as default can be chosen. To do this, execute the following command.
Copysudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
Edit - Manual Java Installation
Download oracle jdk
Copyhttp://www.oracle.com/technetwork/java/javase/downloads/index.html
Extract zip into desired folder
Copy e.g /usr/local/ after extract /usr/local/jdk1.8.0_65
Setup
Copysudo update-alternatives --install /usr/bin/java java /usr/local/jdk1.8.0_65/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8.0_65/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/local/jdk1.8.0_65/bin/javaws 1
sudo update-alternatives --set java /usr/local/jdk1.8.0_65/bin/java
sudo update-alternatives --set javac /usr/local/jdk1.8.0_65/bin/javac
sudo update-alternatives --set javaws /usr/local/jdk1.8.0_65/bin/javaws
Edit /etc/environment set JAVA_HOME path for external applications like Eclipse and Idea
For me non of the above worked and I had to do as below, and it worked,
sudo -E add-apt-repository ppa:openjdk-r/ppa
and then,
sudo apt-get update
sudo apt-get install openjdk-8-jdk
Reference: https://askubuntu.com/questions/644188/updating-jdk-7-to-8-unable-to-locate-package
I am following instructions from here https://linuxconfig.org/how-to-install-java-on-ubuntu-18-04-bionic-beaver-linux but I get "E: Unable to locate package openjdk-8-jdk" in terminal.
Also if i type "java" I get
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless sudo apt install openjdk-8-jre-headless
None of these work either. "E: Package 'default-jre' has no installation candidate"
I am trying to install Ghidra on a newly spun up Debian machine. When I run sudo apt-get install -y openjdk-11-jdk it fails with E: Unable to locate package openjdk-11-jdk. When I run java -version, it says I am running version 16.0.1. How do i revert to the openjkd-11? Or is something else going on that's wrong?
Step 1: Install Java 8 (JDK 8)
Add the webupd8team Java PPA repository in our system and install Oracle java8 using following set of commands.
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
Step 2: Verify JAVA Version
After successfully installing Oracle Java using above step verify installed version using following command.
$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Step 3: Setup JAVA Environment
Webupd8team is providing a package to set environment variables, install this package using following command.
$ sudo apt-get install oracle-java8-set-default
It appears that the downloaded package has corrupted in some way and this is detected by the hash checksum check (that failed as indicated in the error message). It could be either become corrupted on your local machine or on the Ubuntu mirror you're using.1
Try running
sudo apt-get clean all
sudo apt-get update
And then re-attempt the installation.
If that doesn't fix it, try changing the mirror: How can I get apt to use a mirror close to me, or choose a faster mirror?
1 Very unlikely in your case, as you're using the main archive. But for similar other users bumping into this, it is useful to mention.
Hello all.
I just want to ask why there is no package for jdk 1.8 forDebian 12? I've seen one for Sid the open-jdk-8.
Why is it so?
Can I change my sources.list for sid, install open-jdk-8 and then revert sources back to bookworm?
Thank you for your responses.
I recently upgraded my Debian version to the shiny new Debian 12, and I'm currently facing a small hiccup while trying to install OpenJDK-11. I'm aware that the apt install default-jdk command usually does the trick, but in this case, it installs version 17 of OpenJDK. Unfortunately, I specifically need JDK 11 for my project.
I successfully used apt install default-jdk in Debian 11 without any issues, so I'm wondering if there have been any changes in Debian 12 that require a different approach for installing OpenJDK-11. I'd greatly appreciate it if anyone could kindly guide me through the correct steps to install OpenJDK-11 on Debian 12.
Thank you in advance for your time and assistance!