Thursday, December 11, 2008

How to add multiple JARs in Classpath for a Project THE EASY WAY

I found this interesting p0st while browsing this link :

http://vafer.org/blog/20081203024812


I store the classpath in the main .jar’s manifest, the .jar with the class that contains the ‘public static void main(args[]s)’ . Somewhat like this:

Manifest-Version: 1.0
Main-Class: com.test.Launcher
Class-Path:
jcifs.jar
jt400.jar
swingx.jar
swixml.jar
tonytools.jar
jdom.jar
TimingFramework.jar

Just ensure that each jar file has a space before and after on each line. Once done this way, The java application can be launched by using java -jar {mainjar}.jar , or even just double clicking from the desktop.

Much easier, and more cross platform compatable (no .bat for windows, .sh for OS X, etc.)

No comments:

Post a Comment