Skip to content
Advertisement

How to configure Java 7 OR Java 8 dependency in Debian deb package?

I am building a Debian *.deb package for our proprietary software. The software is Java based, so I thought it would be good if the deb package checks for an installed Java package first.

Package: [[name]]
Version: [[version]]
Section: non-free
Priority: low
Architecture: all
Description: [[description]]
Maintainer: company <email @ address>
Homepage: http://product.website
Depends: java7-runtime-headless

Problems:

  • This fails if an Oracle JDK 7 is installed. It seems as this would only check for the OpenJDK 7 package. How can I check for both Java packages, Oracle AND OpenJDK?
  • This fails if OpenJDK 8 is installed but it shouldn’t. Our software runs with Java 7 and Java 8. How can I check for either JDK 7 OR JDK 8?

Summary: How can I configure the Depends: section of my package so dpkg checks for ANY Java/JDK package in version 7 or 8?

Advertisement

Answer

To check for “ANY” Java/JDK package, you can use the pipe symbol (“|“) in the Depends: line. For example, here’s the line for the tomcat7-common package in Jessie:

Depends: libtomcat7-java (>= 7.0.56-3), default-jre-headless | java6-runtime-headless | java6-runtime | java-6-runtime

However, note that if you use a Depends: line, dpkg will only consider it satisfied by packages that it knows about. If someone installs Oracle Java, or some other vendor’s JDK, without using dpkg, or if the .deb doesn’t list the right keywords in a Provides: line, it won’t work. So, you might be better off with a Suggests: or Recommends: line.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement