views:

91

answers:

5

What are the best practices (and enabling tools) to deploy Java standalone applications along with any required jar dependencies, config files, and launch scripts?

Are there any Maven plugins that easies publishing binary releases, so that users don't need to use maven for example?

+3  A: 

As for dependency, I just use maven dependency copy plugin and copy all dependencies into a ./lib folder, and supply a launch script that uses the class path wildcard (that way you can change your dependencies as much as you want and don't have to change the launch script). As for configuration files, I put it in a ./config folder and again include it in my app's classpath in the launch script (The former admittedly only works for > java 1.6).

So in the end almost all my app has the following structure:

mystuff.jar launch.sh
./lib
./config

Then I'll just zip up the whole thing and give it to my users. The whole process is probably easy to automate using maven, but I confess that I do it by hand :p

If you prefer and the licenses permit, you could also just bundle all dependencies into a single jar (with expanded dependencies inside) using the assembly plugin. This tends to make the jar bulky and giving the users an updated app. more difficult. Also I had issues with it several time because of class files getting overwritten or something so I personally stick to the ./lib folder.

Enno Shioji
+5  A: 

Are there any Maven plugins that easies publishing binary releases, so that users don't need to use maven for example?

Use the Maven Assembly Plugin to create a binary distribution as zip/tar.gz/tar.bz2 of your project. This plugin is extremely flexible - at the price of some complexity - and you can do almost anything you want. Then deploy (in the maven sense) the produced artifact, upload it somewhere, etc.

Pascal Thivent
+1  A: 

There's launch4j, which, if you can get it to work, will bundle up a Java app into an executable for your platform.

bmargulies
+1  A: 

If your deployment target supports RPM files, I strongly suggest you investigate the rpm-maven-plugin. It allows you to easily map your project artifacts , including dependencies, to a RPM package.

I've been using it with great success to medium-scale application deployment.

Robert Munteanu
A: 

Take a look at the Appassembler Maven Plugin. You may also want to combine it with the Assembly Maven Plugin.

Use the appassembler plugin to generate a set of "programs" by specifying executable names and main classes. You can also have it prepend and create an etc directory in which you can add configuration files.

If generating the directory with the start-up scripts and directory of binary files isn't enough, you can use the assembly plugin to copy over additional files (say your configuration files) into the appropriate directory and/or package your application into an archive.

deterb