Swing Framework and Components (SFaC) - Application launcher.

This project provides a general-purpose application launcher. The launcher is used to dynamically setup the classpath of the launched application by collecting all the jars of a given directory (usually ./lib).

This project is distributed as a module of the 'Swing Framework and Components' (SFaC) project but it can be used separately. Go to the project main page to have a global description of the 'Swing Framework and Components' project

Usage

Suppose that you have a java application. The startup class (containing main method) of this application is my.App. The code of the application is in a jar file called "MyApp.jar". The application uses log4j and commons-logging.

Then the command line to start the application will look like:

    java -cp MyApp.jar;commons-logging-1.0.4.jar;log4j-1.2.13.jar my.App [some app-specific arg]   

When the number of libraries grows, it become tedious to encode and maintain it. It's specially true when the libraries version number are encoded in the JAR name -- a practice enforced by Maven2 builds (which is, by the way, very good because you always know what you are running).

The idea of the launcher is to put all the jars in a directory (usually called "lib") and say to the application "use all jars in this directory".

The launcher itself come in an additional jar containing only the launcher code (one class: org.sfac.launcher.ApplicationLauncher). Bundling it like that reduce the chances to have classpath problems. But as Maven2 requires on project for one created jar, it ends up to this project containing only one class.

With the launcher and all the jars moved to the /lib directory the application startup command line become:

    java -cp ./lib/Sfac-Launcher-1.0.jar org.sfac.launcher.ApplicationLauncher -d ./lib  my.App [some app-specific arg]   

The command line is now independent of the JAR list required by the application. You just have a reference to the launcher JAR and the "lib" directory.

Using the launcher is completely transparent, it doesn't require any change to the original application packaged in MyApp.jar.

Command line parameters

Here is a full description of available command-line parameters:

java [jvm args] org.sfac.launcher.ApplicationLauncher [-v] [-h] [-r] [-d libPath] <className> [application args]

Where:

Parameter Description
-v Turn on verbose output
-h Display usage
-d libPath set the path of the 'lib' directory (default = '../lib')
This parameter can contain several directory names separated by semicolons.
-r Allow recursive search of jars into libPath sub-directories
className The fully qualified name of the 'main' class of the application
[application args] The parameters passed to the main method of the application