Reputation: 2455
I have a desktop application , which is packaged as a self-executable jar file, but my code needs to access many jar files , which i have set in the class-path in the manifest file. But the problem that I am encountering is that all the jars to be used in the class-path I have to keep them in the same directory as my executable jar file.What I need is to somehow merge all the various jars so that I can specify this single jar in my class-path in .mf file. The .mf file is-->
Class-Path: poi-3.7-20101029.jar poi-examples-3.7-20101029.jar poi-ooxml-3.7-20101029.jar poi-ooxml-schemas-3.7-20101029.jar poi-scratchpad-3.7-20101029.jar jfreechart-1.0.14.jar jcommon-1.0.17.jar jfreechart-1.0.14-experimental.jar jfreechart-1.0.14-swt.jar junit.jar servlet.jar swtgraphics2d.jar gnujaxp.jar iText-2.1.5.jar
Main-Class: gui/GUILauncher
Kindly suggest me a solution, so that I can achieve my objective...
Upvotes: 0
Views: 622
Reputation: 1760
You need not keep all these jars in executable jar directory. Instead you could specify relative path of dependent jars in Manifest.mf file. e.g. You have kept your executable jar under bin folder and dependent jars under lib folder. app-root + + \bin + + GuiLauncher.jar + + \lib + junit.jar + servlet.jar
Manifest.mf Classpath will be
Class-Path: ..\lib\junit.jar ..\lib\servlet.jar
Upvotes: 0
Reputation: 347244
You could specify a path to each at file in the manifest
Class-Path: lib/poi-3.7-20101029 ...
And store the library jars here.
While I like the idea of combining all he classes into a single Jar, you need to be careful of resources that might share the same path. We have this issue in our app, all our Jars contain a Version file we use as a marker and read via Class.getResources(...)
Upvotes: 1