adrien.pain
adrien.pain

Reputation: 453

Combine or merge all jars in one executable jar

Kind of a "simple" question here, but it seems complicated to do such a thing using Eclipse.

I have a "utils" project, in which I have developped "common" code like xml parsers, loggers, maths calculations, debug utilities and such.

This library is based on several other external libs (commons-lang-3.1, colt-1.2.0, jdom-2.0.4) to work, and it's a non-runnable JAR file (ie, there is no main(), just utility code to include in other projects).

What I want to do is, when I create the JAR file of my project, extract all external JARs (common-lang, colt, jdom) in the JAR file, in order to automatically use them on other projects.

The reason is that I don't want to re-include common-lang, colt and jdom on every projects based on my lib, but use the ones packed in my lib JAR file (and it's a way to ensure that I'll be using the same version of those libs in the projects based on my lib, too)

I know how to do that with a runnable JAR file. See for instance : How to create a jar with external libraries included in Eclipse?

But in a non-runnable JAR file :

Is there a simple way to export this JAR file with a directory structure in which all external JARs files are extracted in the generated JAR file, too ?

Regards

Upvotes: 2

Views: 4591

Answers (1)

Paul Vargas
Paul Vargas

Reputation: 42030

Have you seen JarSplice?

JarSplice merge all your jars and native files into one, easy to use executable jar file via an easy to use GUI.

enter image description here

Upvotes: 3

Related Questions