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 commandssudo apt-get install software-properties-commonsudo apt-get install python-software-propertiessudo add-apt-repository ppa:openjdk-r/ppasudo apt-get updatesudo apt-get install openjdk-8-jdkBut I got this errorReading 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 updatessudo update-alternatives --config javaand the output wasThere 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.
Install JDK 8 on Debian
java;debian
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-8On 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-4Now 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-freedeb http://security.debian.org/ jessie/updates main contrib non-freedeb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-freedeb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-freeNow update the index, it should say something like this at the very end - Reading package lists... DoneBuilding dependency tree       Reading state information... Done6 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-8to 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. 