As all of you probably know, we are building the BlogBridge application – the next generation of feed aggregators. At the present moment we are distributing the application in two forms: as Java Web Start application and ZIP-packaged Java application available for download from Lately, we started to think how to create native installation/uninstallation experience for our users on different platforms. We decided to support native installations for Windows, Mac OS X, generic Tar.GZ archives and Debian packages.

In this tutorial I will share the basics of Debian package creation for Java applications.

So where do we start? We start from understanding the rules of placing application requisites on the user’s filesystem. Typical Java application has main JAR, number of libraries in form of third-party JAR’s, icon file and shell script to start the application itself. As all Unix/Linux users know, executable applications always reside in /bin and /usr/bin folders, libraries are in /lib and /usr/lib and icons are in the application folder inside the /usr/share/doc folder. The placement rules tell that it’s better to use the directories under /usr for user-space applications. So, here is what we end up with:


At this moment we have our deployment structure ready for packaging into DEB package, but wait a second… We will need at least DEB package control descriptor to let the user know what this application is about.

Let’s create a very simple descriptor:

Package: myapp
Version: _version_
Section: web
Priority: optional
Architecture: all
Maintainer: Aleksey Gureev
Description: my first sample application which isn’t
 doing anything special.
 And other description goes
 here too.

Please note that each line of Description starts with space (or dpkg will interpret first word of it as a field) and empty lines have dot.

This descriptor tells package management applications all information necessary to describe the package contents to the user. Put this descriptor into the file named “control”.

The next step is to create the directory structure for dpkg application to convert into DEB package. Build the directory structure below somewhere in the temp folder:


Now populate the directories as we defined above and put “control” file into DEBIAN directory. The last step is to issue proper dpkg command. Here it is:

dpkg --build debian

It will produce “debian.deb” which can be renamed into something more meaningful, like “myapp-1.0.deb”.

Now your Java application is ready for installation on Debian systems like any other native application! Was it simple?

Though, I did another additional step to make things even more perfect – I managed to add the application to the Gnome Applications menu. It appeared to be very easy and installation started to look really professional. In order to add the item to the menu of Gnome you need small descriptor which should be added to /usr/share/doc/applications directory during installation. Here’s sample descriptor for Internet application:

[Desktop Entry]
Name=My Application
Comment=My First Application

This descriptor file should be named “myapp.desktop”. Of course, only the extension is mandatory and main name can be different. The last stroke is to add corresponding directory and this descriptor to the package source hierarchy and rebuild DEB package. Have a practice!

To be absolutely sure that you don’t violate any good package’s rules you can use very convenient application “lintian”. It will analyze the package you’ve just created and outline all violations. You can feed the output log from “lintian” to “lintian-info” to get very detailed explanations of your package problems with references to source standards documents. Pure power on the fingertips!

That’s all for now. In my future plan to learn how to install KDE menu items. Maybe something else – not sure yet.

Package it!