Debian Java packaging examples

Here are a selection of example debian dirs for simple Java packages of a variety of types. They all use javahelper and dh7 in order to reduce the complexity of packaging.


Example Packages

Simple library using ant

This example is for a Java library using ant as the build system

Debhelper will use ant to automatically build and clean a package with a build.xml. This assumes that ant will build the javadoc and jar file correctly. Javahelper installs the jar and javadoc for you as before.

Upstream build-systems often miss things like including the classpath in the jar manifest. the .classpath file fixes this. They also won't be linking against the javadoc files in the correct locations, which is why a patch is needed to fix this.

See the contents of this example: Debian dir (download).

Simple library, no dependencies, no existing build system

This example is for a Java library that does not depend on any other packages and which either does not have a build system shipped from upstream or you do not wish to use it.

All the heavy lifting is done for you by javahelper including building the classes, installing the jars, creating javadoc etc. All you have to do is fill out the javabuild, javadoc and jlibs files and declare your JAVA_HOME in debian/rules.

See the contents of this example: Debian dir (download).

Simple library, with dependencies on other libraries, no existing build system

This example is for a Java library that which does depend on other packages, but which either does not have a build system shipped from upstream or you do not wish to use it.

Very similar to the previous example; the differences are the addition of build-dependencies and declaring the CLASSPATH in debian/rules

See the contents of this example: Debian dir (download).

A java program depending on a library, but with no existing build system

This example is for a Java program that which does depend on other packages, but which either does not have a build system shipped from upstream or you do not wish to use it.

Note the two overrides in debian/rules which cause the jar to become executable and have the correct Main-Class manifest entry. This then causes dependencies on the matching JRE to the JVM you compiled with and also jarwrapper to be added to the package.

See the contents of this example: Debian dir (download).

Simple program using ant

This example is for a Java program using ant as the build system

Debhelper will use ant to automatically build and clean a package with a build.xml. The jar is installed and linked as in the non-ant version.

Upstream build-systems often miss things like including the classpath and main-class in the jar manifest. For more complicated manifest updating we use the .manifest file.

See the contents of this example: Debian dir (download).