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?
Can I indicate that a .deb package depends on Java, but not specify what implementation (e.g. OpenJDK, IcedTea, Oracle)?
java;deb
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-runtimeorDepends: default-jre-headless | java6-runtime-headless | java6-runtimeetc.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), 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).