0

I want to install jdk and jre in my ubuntu 14.04 and I got these following errors:

anil@anil:~$ sudo apt-get install default-jre
[sudo] password for anil: 
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 (= 2:1.7-51) but it is not going      to be installed
Depends: openjdk-7-jre (>= 7~u3-2.1.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Ravan
  • 9,379

6 Answers6

3

First run these commands in terminal (press Ctrl+Alt+T):

  • sudo apt-get --fix-broken install
  • sudo apt-get clean
  • sudo apt-get autoclean
  • sudo apt-get autoremove
  • sudo dpkg --configure -a
  • sudo apt-get update then following

    1. Changed software and updates to main server

    2. Unmarked all "other software" sources

ims

  1. Reload it and run for software update,it installed tzdata(i think this is the reason)

  2. Run

    sudo apt-get install openjdk-7-jdk openjdk-7-jre-headless
    
Ravan
  • 9,379
1

I'm in China and after I changed the sources of apt-get to certain China mirror, I got the error. Then I changed it back to default sources and succeeded.

1

In regards to the broken packages, try installing the same package with aptitude. it will give up less easily, and will attempt to find solutions which may involve modifying other packages.
You can also get a list of held packages with dpkg --get-selections | grep hold, which could show you the issue.

Otherwise, maybe try installing openjdk and jre:

Doing a apt-cache search jdk or apt-cache search jre lists a lot of packages that might interest you. To install open JDK and JRE you would use
sudo apt-get install openjdk-7-jdk openjdk-7-jre-headless
you can replace the 7 with 6 or 8 if you would prefer openjdk 6 or 8

EDIT:
Fixed apt-get command, thanks @lesslazy

Noctane
  • 11
  • 8
  • anil@anil:~$ sudo apt-get install openjdk-7-jdk open-jdk-7-jre Reading package lists... Done Building dependency tree
    Reading state information... Done E: Unable to locate package open-jdk-7-jre
    – Ravan Aug 14 '15 at 05:36
1

Your computer is missing packages needed to install default-jre.
Update the package list sudo apt-get update and then run sudo apt-get -f install this may fix the problem. or you can run sudo apt-get install openjdk-7-jdk openjdk-7-jre-headless
The last command is same as @Noctane said except he made a typo mistake in the command.

0

You can try this:

sudo apt install python-software-properties
sudo add-apt-repository ppa:webupd8team/java

Then, you will need to fully update the system with the following command:

sudo apt update

You can also install Java by using one of the following commands:

sudo apt install oracle-java6-installer
sudo apt install oracle-java7-installer
sudo apt install oracle-java8-installer
0

Maybe: 1) Try this: http://www.upubuntu.com/2013/05/how-to-fix-broken-packages-using.html 2) Try to install java again.

Mario Kamenjak
  • 1,043
  • 3
  • 16
  • 25