Cannot install openjdk-8-jre-headless on Debian Jessie
This Friday I saw that I had 2 held back packages for some reason when I ran apt-get upgrade
, so naturally I did what any inexperienced sysadmin would do and uninstalled the packages in the hopes that I could simply re-install them and the problem would be solved.
Little did I know, I just made the situation worse. When I tried to reinstall openjdk-8-jre-headless
, I got this:
$ apt-get install openjdk-8-jre-headless
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
openjdk-8-jre-headless : Depends: ca-certificates-java but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I tried to upgrade the mentioned package manually, but to no avail.
$ apt-get upgrade ca-certificates-java
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... ca-certificates-java is already the newest version.
Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Looking around I saw no mention of a solution to this exact error anywhere.
I use ElasticSearch on the server, which I restarted, but I should've expected that it wouldn't start up at this point. So now I'm without Java and my users are without search. What is going on and how can I fix this?
Solution 1:
This worked for me:
apt install -t jessie-backports openjdk-8-jre-headless ca-certificates-java
REF: https://unix.stackexchange.com/questions/342403/openjdk-8-jre-headless-depends-ca-certificates-java-but-it-is-not-going-to-be
Solution 2:
-
First you need to add
jessie-backports
repo.echo "deb http://http.debian.net/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
-
install commands
sudo apt-get update sudo apt-get install -t jessie-backports openjdk-8-jre-headless
-
switch to new java
sudo /usr/sbin/update-java-alternatives -s java-1.8.0-openjdk-amd64
Reference: https://github.com/OpenTreeOfLife/germinator/wiki/Debian-upgrade-notes:-jessie-and-openjdk-8