Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I try entering this to install java JDK

 sudo apt-get install openjdk-7-jdk

It responds with this

Reading package lists... Done
Building dependency tree... 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-7-jdk : Depends: openjdk-7-jre (= 7u55-2.4.7-1ubuntu1~0.12.04.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I have no idea how to deal with this.

share|improve this question

migrated from stackoverflow.com Jul 1 at 15:00

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

1  
You forgot to do a sudo apt-get update first? –  Jorge Castro Jul 1 at 15:01
    
I'm running x64 12.04 and adding the PPA from webupd8team or trying to install openjdk as an alternative via apt-get still resulted in the 'unmet dependencies' error. The answer on this other post is what solved it for me. –  Sherry Taylor Aug 5 at 22:49

3 Answers 3

Here is how I usually install JDK (from a terminal)

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java7-installer

More instructions over at https://launchpad.net/~webupd8team/+archive/java

share|improve this answer
    
It's the official version from Oracle, not the OpenJDK version, though. But personally, I prefer the version from Oracle, since it is the one most commonly used. –  Puce Jul 1 at 12:50
    
Also consider to install oracle-java7-set-default or oracle-java8-set-default depending on which JDK version should be the default on your system. –  Puce Jul 1 at 12:53

I suggest 2 solutions for you:

1. You follow this tutorial to resolve your problem: http://askubuntu.com/a/142808

OR:

2. Install Install Oracle Java 8 (JDK 8u5 - lastest and stable version) in Ubuntu:

Step 1: Install Java 8 (JDK 8) Add the webupd8team java PPA repository in our system and install Oracle java8 using following set of commands:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer


Step 2: Verify JAVA Version After successfully installing oracle java using above step verify installed version using following command:

java -version


Step 3: Setup JAVA Environment Webupd8team is providing a package to set environment variables, Install this package using following command:

sudo apt-get install oracle-java8-set-default
share|improve this answer

Personally I don't like using package managers to install the JDK(and by extension the JRE) I typically perform the following:

share|improve this answer
    
What's the issue with the package manager? Personally, I find it great! –  Puce Jul 1 at 12:55
    
1. Less experienced dev's do not know how to setup their environment. 2. They are not aware what version they are using. 3. To it is first principals knowledge, it always serves me well. –  user3465651 Jul 1 at 14:27
1  
Really? Someone can do all these stuff you mentioned but cannot execute sudo add-apt-repository ppa:webupd8team/java and doesn't know which OS version they installed? That's a rare case, I would guess. –  Puce Jul 1 at 14:41
    
I'm a bit picky when it comes to my java tools. I like installing them myself. 1 other point, if I need multiple version of java on the system for testing(Like attempting to simulate a client environment) I can have multiple jdk's present(Previous companies I have worked at have not really made use of VM or docker like apps) –  user3465651 Jul 1 at 14:49
    
Sure, there are situation where the easiest way is to install the JDK manually as you suggest, but I found the package manager to be the easiest way to install and update (security updates etc.) the JDK in most cases. Just my 2 cents. –  Puce Jul 1 at 14:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.