I have a .deb package that contains an app, which requires Java to function. However, I don't care which implementation they have installed (e.g. OpenJDK, IcedTea, Oracle), and I don't want to force a user to download another implementation if they have one installed. I also want to handle the situation of a user not having any implementation installed.

Is there a way that I can indicate that the .deb package requires any Java implementation? And if so, how do I handle them not having any implementation installed?

2 Answers 2


The standard way of indicating that a .deb package requires a Java runtime environment (the JVM, not the JDK) is to specify a dependency on default-jre or default-jre-headless (the former for programs with GUIs, the latter if no GUI is necessary), with alternative dependencies on the appropriate versions of java-runtime (java6-runtime if your application uses Java 6 or later, java7-runtime for Java 7 or later, etc.):

Depends: default-jre | java6-runtime


Depends: default-jre-headless | java6-runtime-headless


This handles all the Debian-provided JREs (or Debian derivatives), and the Oracle JREs if they were processed using java-package. default-jre depends on the default JRE (OpenJDK 7 for Debian 8, OpenJDK 8 for Debian 9, OpenJDK 11 for Debian 10), so if no other JRE is installed, this ensures a JRE is installed. The various JRE packages provide java-runtime variants depending on their level of support, so depending on that means that any existing, compatible JRE, suitably packaged, will be used instead of forcing the user to install yet another JRE.

If you really want to support any installed JRE though, including manually-installed, unpackaged Oracle JREs, you can only use the above in the package's "Recommends" stanza, and then try running java from your startup script. Ideally you should check for the presence of a JRE at installation time (in postinst, but making sure you don't fail the install if no JRE is found), and whenever you need to run java — which may be complicated if your package contains an initscript or systemd unit or the like (complicated in the sense that it's not obvious how to notify the administrator that something is wrong, in a way you can be sure will be noticed and understood).

  • What happens if there is no JRE is installed and I specify a dependency of default-jre? Is it able to pick an implementation to automatically install or does the user have to specify one? Commented Jun 24, 2016 at 7:49
  • default-jre defines the implementation to install, so the user doesn't have to specify one. For Debian 8, it's OpenJDK 7; for Debian 9 it should be OpenJDK 8. Commented Jun 24, 2016 at 8:26

If you insert this into the control file you can specify the minimum java version and also specify a java implementation to be installed if no appropriate java version is installed yet:

Depends: openjdk-21-jdk-headless | java-sdk-headless (>= 21), ...

java-sdk-headless is a virtual package, which is provided by any java 21 compatible runtime.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .