my application needs multiple jars to work. Since it is a desktop application i can not hold the user responsible of installing. So in my build script i unzip the jars content in to my build directory delete manifest files, compile my software and jar it again. Everything works as it should my question is are there any long term side effects to this process?
8 Answers
In the past, there were JARs with weird content (like the DB2 driver which contains com.ibm
and com.IBM
; after decompressing in a Windows filesystem, those two packages would be merged).
The only issue you need to be aware of are signed jars and other files in META-INF which might have the same name in multiple source JARs.
A simple solution for all these issues is to use One-JAR. It allows to wrap several JARs into one without unpacking them, first. And read this answer: Easiest way to merge a release into one JAR file

- 1
- 1

- 321,842
- 108
- 597
- 820
A simpler solution (IMO) is using Maven's assembly plugin, which is also described in one of the answers to another question which was linked to in a previous Q&A. This is provided you are using Maven (which is a recommended tool by its own right) as a build tool.
If you want a no fuss way for the end user to kick off a program with multiple jar dependencies you may want to look at Launch4j or Jsmooth (I prefer Launch4j). Both are programs that create executables that wrap jar(s) and the JRE together so that to the end user it appears no different then any other executable.

- 48,506
- 64
- 207
- 283
Another great option is ProGuard, which can also shrink and/or obfuscate the code too.

- 63,018
- 25
- 139
- 189
-
hmm, 10 years ago and 2 upvotes. wonder if it's the same now :) – dtc May 24 '19 at 03:10
If some of the jars are signed you lose the signature by unpacking/repacking it.

- 15,585
- 8
- 51
- 82

- 6,120
- 9
- 46
- 60
If your primary target platform is Windows desktop, then you could also consider generating an Windows native exe from the jars of your application

- 113
- 2
- 4
One-JAR will do the job, and has a new release (0.97) which supports frameworks like Spring and Guice, which users are now packing into One-JAR archives. http://one-jar.sourceforge.net
Ference Hechler also did some great work inside Eclipse with the Eclipse export wizard: we worked together on FatJar/One-JAR from which the Eclipse work grew, and I can recommend that as an approach, though I don't know how well it handles the frameworks.

- 886
- 7
- 6
Well you're throwing away the MANIFEST of your third party jars, so that could cause you problems. For example you could be causing security issues by throwing away the "Sealed" attribute.
Why not just create a simple installer and a script to launch your application which sets the CLASSPATH correctly?

- 21,816
- 3
- 61
- 76