1

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.

2
  • 1
    You forgot to do a sudo apt-get update first? Jul 1 '14 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. Aug 5 '14 at 22:49
6

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

2
  • 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 '14 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 '14 at 12:53
2

I suggest 2 solutions for you:

1. You follow this tutorial to resolve your problem: https://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
0

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

6
  • What's the issue with the package manager? Personally, I find it great!
    – Puce
    Jul 1 '14 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 '14 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 '14 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 '14 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 '14 at 14:58

Your Answer

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