46

Can't install Java8

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've searched Google and I've added repos and other suggestions, but nothing has allowed me to install Java 8 yet.

ideas?

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.7 (jessie)
Release:        8
Codename:       jessie
Jason
  • 1,714
  • 5
  • 25
  • 30
  • 1
    Facing the same problem here. It was working till yesterday. Today it initially complained about ca-certificates-java and now can't even find the package. – Jay Feb 04 '17 at 05:35
  • 1
    Just interesting, why don't you want to install oracle version? – ka3ak Feb 04 '17 at 07:26
  • @ka3ak what is the oracle install version? I tried doing an apt-get install with a package that had install and oracle in it but it did not work. – Jason Feb 04 '17 at 15:32
  • 1
    @FrankThornton Here is how I installed it on my system (Kubuntu): sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer Source: http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html – ka3ak Feb 04 '17 at 16:14
  • Thanks! I was pretty sure I tried that or at least something kinda like that and had issues. I may have had a different repo. – Jason Feb 04 '17 at 16:23
  • @ka3ak because I don't like adding extra repos. As far as I can tell, the openjdk builds are close enough to the performance of the standard oracle builds ( not true in 6, but true now ) that the extra steps / security of an extra repo created by "webupd8team" is not necessary and extra risk. – Brian Bulkowski Feb 10 '17 at 17:38
  • Can't answer b/c not enough reputation. Here's the process that worked for me: (1) install ca-certificates-java ALONE first. This installed the version of Java that it is meant for processing it. Then (2) install openjdk-8-jre-headless. Then (3) use update-alternatives to set the Java version to openjdk-8. – johnnyb Oct 06 '22 at 16:43

5 Answers5

90

is this jessie? With backports

apt install -t jessie-backports  openjdk-8-jre-headless ca-certificates-java
  • Backport issue looks like. That allowed it to install. – Jason Feb 04 '17 at 15:31
  • 1
    That worked for me, too. Mind adding an explanation what the `-t` parameter does and how this resolves the issue? – hheimbuerger Apr 17 '17 at 15:22
  • 1
    The option -t tells apt, from which source it should install the package. `aptitude why-not ca-certificates-java` gives `p openjdk-8-jre-headless Beschädigt ca-certificates-java (< 20160321~) ` You need the Version from jessie-backports. `apt-cache policy ca-certificates-java ca-certificates-java: Installiert: 20140324 Installationskandidat: 20140324 Versionstabelle: 20161107~bpo8+1 0 100 http://http.us.debian.org/debian/ jessie-backports/main amd64 Packages *** 20140324 0 500 http://http.us.debian.org/debian/ jessie/main amd64 Packages` –  Apr 18 '17 at 08:34
9

It is not working from Jessie backports. I tried stretch and it got installed.

echo 'deb http://ftp.au.debian.org/debian/ stretch main contrib non-free' > /etc/apt/sources.list.d/stretch.list && \
apt-get update && \
apt-get install -y --no-install-recommends openjdk-8-jre-headless && \
rm /etc/apt/sources.list.d/stretch.list && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

P.S.: I used an Australian mirror since I am here. Choose the best for you from here.

chaos
  • 47,463
  • 11
  • 118
  • 144
Jay
  • 191
  • 3
3

this worked for me many thanks, note you got an extra 'deb' in your echo i had to remove, i am also in Oz but this should work on all repos by now, seems it was an issue with certificates for fixed list of java versions

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851667

  • 3
    [Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.](http://unix.stackexchange.com/help/how-to-answer) – Kusalananda Feb 04 '17 at 09:02
1

I keep hitting this issue. Very frustrating. I have automated packer builds and when the jdk/jre are updated this issue can resurface. after much hair pulling i've found this to be fairly reliable and fully automateable.

note that you mush have a backports repo properly defined as mentioned in other parts of this page. my image came with it pre set up. yours however, may not.

  1. install ca-certs from backports
  2. install jre and jdk + headless as a second command

    sudo apt install -t jessie-backports ca-certificates-java
    sudo apt-get -y install openjdk-8-jdk openjdk-8-jre openjdk-8-jdk-headless openjdk-8-jre-headless
    

running the two together will prompt for a Y/N response on a config file, which are annoying to automate. so they MUST be run separately if you want this to work w/o human interaction.

mchotsun
  • 11
  • 2
0

This works for me

apt-get install software-properties-common
add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
apt-get update
apt-get install oracle-java8-installer

referring guide