unable to install jdk and jre in ubuntu 14.04

29,521

Solution 1

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
    

Solution 2

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.

Solution 3

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

Solution 4

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.

Share:
29,521

Related videos on Youtube

Ravan
Author by

Ravan

Updated on September 18, 2022

Comments

  • Ravan
    Ravan over 1 year

    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.
    
    • orvi
      orvi over 8 years
      can you provide me the output of /etc/apt/sources.list?
    • Ravan
      Ravan over 8 years
      can you provide me the output of /etc/apt/sources.list? anil@anil:~$ /etc/apt/sources.list bash: /etc/apt/sources.list: Permission denied
    • orvi
      orvi over 8 years
      login as root
    • apkg
      apkg about 8 years
      You've probably turned off automatic updates to stop it bugging you! Turn it back on? This worked for me.
  • Ravan
    Ravan over 8 years
    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