1

This question already has an answer here:

I am trying to install JDK 8 on Debian. I found a lot of similar topics but none of them solved my problem. In most topics the solution was this commands

sudo apt-get install software-properties-common
sudo apt-get install python-software-properties

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk

But I got this error

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-jdk : Depends: openjdk-8-jre (= 8u111-b14-2~bpo8+1) but it is not going to be installed Depends: openjdk-8-jdk-headless (= 8u111-b14-2~bpo8+1) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

I also checked for updates

sudo update-alternatives --config java

and the output was

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java Nothing to configure.

marked as duplicate by Stephen Kitt debian Mar 14 '17 at 11:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Nov 27 '16 at 15:04

This question came from our site for professional and enthusiast programmers.

  • Would you please add your version of Debian? For openjdk, you should not need to add Ubuntu repositories. – Rui F Ribeiro Nov 27 '16 at 15:37
0

The first thing is always see the Debian PTS to have an idea of what options are available to you. For instance, if I go to -

https://tracker.debian.org/pkg/openjdk-8

On the left-hand side you have something called versions - can you see it, it shows -

  stable-bpo: 8u121-b13-1~bpo8+1
     testing: 8u121-b13-3
    unstable: 8u121-b13-4

Now stable-bpo means it is in backports. the backports page describes its function excellently, see https://backports.debian.org/

So you need to add as shared by @Reto as well the backports address to the list of packages that you already have -

deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free

Now update the index, it should say something like this at the very end -

Reading package lists... Done
Building dependency tree       
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.

Don't see the number of packages that can be upgraded as that's a function of how many packages I have, how often I update packages etc. If the four lines are similar to above, that means the index updation went without a hitch, no errors.

Once that is done you could simply do -

$ aptitude search openjdk-8

to get a listing of how many different openjdk-8 packages are listed or not. For instance I'm on testing and there are quite a few here. We also have openjdk-9 as well.

Once you get it , just install as you were trying to install before -

$ sudo aptitude install openjdk-8 

and let aptitude handle all the dependancy resolution. If you still have issues, let us know here.

1

openjdk-8 is available in my default Jessie/stable install - just need to apt-get install it (openjdk-8-jdk and whatever else you want/need that it recommends or depends on)

Of course, it MAY depend on your /etc/apt/sources.list file including the contrib and non-free repositories

/etc/apt/sources.list should look something like

deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free
  • 2
    deb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free is the important part – Reto Dec 2 '16 at 9:49
0

Problem not solved here...

# cat /etc/apt/sources.list

#deb hxxp://debian.mirrors.ovh.net/debian/ jessie main contrib non-free
#deb-src hxxp://debian.mirrors.ovh.net/debian/ jessie main contrib non-free

deb hxxp://security.debian.org/ jessie/updates main contrib non-free
deb-src hxxp://security.debian.org/ jessie/updates main contrib non-free

# jessie-updates, previously known as 'volatile'
deb hxxp://debian.mirrors.ovh.net/debian/ jessie-updates main contrib non-free
deb-src hxxp://debian.mirrors.ovh.net/debian/ jessie-updates main contrib non-free

# jessie-backports, previously on backports.debian.org
deb hxxp://debian.mirrors.ovh.net/debian/ jessie-backports main contrib non-free
deb-src hxxp://debian.mirrors.ovh.net/debian/ jessie-backports main contrib non-free

deb hxxp://debian.mirrors.ovh.net/debian/ jessie main contrib non-free
deb-src hxxp://debian.mirrors.ovh.net/debian/ jessie main contrib non-free

# apt-get install openjdk-8-jdk

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-jdk : Depends: openjdk-8-jre (= 8u121-b13-1~bpo8+1) but it is not going to be installed
                 Depends: openjdk-8-jdk-headless (= 8u121-b13-1~bpo8+1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
  • whhy hxxp, it should be http:// as shared by ivan below. – shirish Mar 10 '17 at 15:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.