Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm in the process of creating a .deb package of our Java-based application (see this superuser-question). I'm now using following dependency information:

Depends: java-runtime-headless (>= 1.6)
Recommends: openjdk-7-jre-headless, ...

Now I'm trying to install it:

$ sudo dpkg -i MYAPP.deb 
Selecting previously unselected package MYAPP.
(Reading database ... 140874 files and directories currently installed.)
Unpacking MYAPP (from MYAPP.deb) ...
dpkg: dependency problems prevent configuration of MYAPP:
 MYAPP depends on java-runtime-headless (>= 1.6); however:
  Package java-runtime-headless is not installed.
dpkg: error processing MYAPP (--install):
 dependency problems - leaving unconfigured
Processing triggers for desktop-file-utils ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for gnome-menus ...
Errors were encountered while processing:

OK, I'm trying to install the dependency:

$ sudo apt-get install java-runtime-headless
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package java-runtime-headless is a virtual package provided by:
  openjdk-7-jre-headless 7u25-2.3.10-1ubuntu0.12.04.2
  openjdk-6-jre-headless 6b27-1.12.6-1ubuntu0.12.04.2
  gcj-jre-headless 4:4.6.3-1ubuntu5
  gcj-4.6-jre-headless 4.6.3-1ubuntu2
  default-jre-headless 1:1.6-43ubuntu2
You should explicitly select one to install.

E: Package 'java-runtime-headless' has no installation candidate

OK, I chose one of these packages:

$ sudo apt-get install openjdk-7-jre-headless
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 openjdk-7-jre-headless : Depends: openjdk-7-jre-lib (= 7u25-2.3.10-1ubuntu0.12.04.2) but it is not going to be installed
                          Depends: ca-certificates-java but it is not going to be installed
                          Depends: tzdata-java (>= 2012e-0ubuntu0.12.04.1) but it is not going to be installed
                          Depends: java-common (>= 0.28) but it is not going to be installed
                          Depends: libnss3-1d (>= 3.12.9+ckbi-1.82-0ubuntu4) but it is not going to be installed
                          Recommends: icedtea-7-jre-jamvm (= 7u25-2.3.10-1ubuntu0.12.04.2) but it is not going to be installed
 MYAPP : Depends: java-runtime-headless (>= 1.6)
         Recommends: mercurial but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Now it only suggests me to remove my application:

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
1 not fully installed or removed.
After this operation, 41.0 MB disk space will be freed.
Do you want to continue [Y/n]? n

It looks like I first need to install the dependency (openjdk-7-jre-headless) and then my application. How a normal user should understand that? Or is there a better way to install MYAPP.deb?

share|improve this question
up vote 4 down vote accepted

I would remove the version from your "java-runtime-headless" dependency.

Virtual packages suffer from some troubling limitations, the most significant of which being the absence of a version number.

If you want to specify which of a set of real packages should be the default to satisfy a particular dependency on a virtual package, you should list the real package as an alternative before the virtual one.

share|improve this answer

So, why did you aborted the execution of sudo apt-get -f install. Run it again and don't abort it.

After run these commands:

sudo apt-get clean
sudo apt-get autoclean
sudo dpkg --configure -a

Then run again:

sudo apt-get -f install

If the output is something like:

0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded

then run:

sudo apt-get -u dist-upgrade

See How do I resolve unmet dependencies? for more about.

Now install java-runtime-headless using the following command:

sudo apt-get install openjdk-7-jre-headless

And finally, install your application:

sudo dpkg -i MYAPP.deb 
share|improve this answer
I aborted it, because it wanted to remove MYAPP. – Thomas S. Oct 21 '13 at 7:11
Well, I want MYAPP to be installed with dependencies, not to be removed. – Thomas S. Oct 21 '13 at 7:17
@ThomasS. The last line/command from my answer will do this :) – Radu Rădeanu Oct 21 '13 at 7:22
@ThomasS. So, have you tried to clean and then install as I said? Something changed? – Radu Rădeanu Oct 22 '13 at 11:58

As NGRhodes suggested I changed the dependencies to

Depends: openjdk-7-jre-headless | java-runtime-headless, ...
Recommends: ...

Now I can install it with

$ sudo dpkg -i MYAPP.deb

and install the missing dependencies with

$ sudo apt-get -f install
share|improve this answer
You might want to consider marking my answer as the accepted one. – NGRhodes Oct 24 '13 at 8:51
Or editing @NGRhodes answer to give completness. – Braiam Nov 26 '13 at 14:38

Your Answer


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

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