I am trying to install java in Ubuntu but it is giving me this error:

$ sudo apt-get install default-jre
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:
 default-jre : Depends: default-jre-headless (= 1:1.6-43ubuntu2) but it is not going to be installed
               Depends: openjdk-6-jre (>= 6b23~pre11-1ubuntu1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

When I try to install anything from Software Center either

It shows me this error:

[package dependencies could not be resolved

When I go to Software Center > Edit > Software Sources is disabled.

I have tried many solution but nothing works:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get clean
sudo apt-get autoclean 

I tried this Stack Overflow answer

This the result of apt-cache policy default-jre and apt-cache policy default-jre-headless.

$ apt-cache policy default-jre
  Installed: (none)
  Candidate: 1:1.6-43ubuntu2
  Version table:
     1:1.6-43ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main i386 Packages

$ apt-cache policy default-jre-headless
  Installed: (none)
  Candidate: 1:1.6-43ubuntu2
  Version table:
     1:1.6-43ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main i386 Packages

When I tried dpkg --get-selections | grep hold it does't show any error!


Thought it would have been from actually "held" packages, but maybe not, or maybe not the only problem...

I've seen similar errors before caused from using non-standard repositories (wrong version/distro, odd private or PPAs). You might want to check your repos and try to reset them to "defaults."

This may not solve the problem, but making a backup copy of your current repos (sources.list... files) it would be easy to check & undo later.

Here's info from another answer of mine on Restoring Default Ubuntu Sources:

Backup the sources.list files

Just copy them to a backup folder somewhere, this should work:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
sudo cp -R /etc/apt/sources.list.d /etc/apt/sources.list.d.old

or put the copy in your home somewhere:

sudo cp -R /etc/apt/sources.list* /home/myuser/

Restoring the default Ubuntu sources.list

  • For Ubuntu, if you do this it should generate a new fresh sources.list file

    1. delete the old files (sudo rm /etc/apt/sources.list and sudo rm -R /etc/apt/sources.list.d but BACKUP FIRST).

    2. Then do either of:

      • Run the Software Sources (from the programs menu / dash, or sudo software-properties-gtk or sudo software-sources) select/check-mark some repos, pick a server and update.

      • OR Generate a new one at http://repogen.simplylinux.ch/ using your version & country (to pick local mirrors), then copy & paste it into your new sources.list with
        gksudo gedit /etc/apt/sources.list
        or in a terminal with
        sudo nano /etc/apt/sources.list

The site http://repogen.simplylinux.ch/ has a LOT of optional PPAs too. [courtesy of How do I restore the default repositories? ]

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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