Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying Java Files

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?

like image 993
notnoop Avatar asked Jul 18 '10 19:07

notnoop


2 Answers

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.

like image 167
Pascal Thivent Avatar answered Sep 25 '22 21:09

Pascal Thivent


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.

like image 34
Enno Shioji Avatar answered Sep 25 '22 21:09

Enno Shioji