JARs containing JARs

A

alan

Is it possible to create a jar that contains its dependant jars so
that you can distrbute an application as a single jar?
 
M

millerch

Why not unzip the dependant jars and create a new jar containing your
application, and all its dependant class files?
 
S

Steven Green

Why not unzip the dependant jars and create a new jar containing your
application, and all its dependant class files?

Unziping is simple enough admittedly, but I personally would
not want to mess with someone elses library. If there is a way to
nest jar files I would love to hear about it.

--Steve
 
L

Lee Fesperman

Steven said:
Unziping is simple enough admittedly, but I personally would
not want to mess with someone elses library. If there is a way to
nest jar files I would love to hear about it.

You can't load classes from nested jars. You could write your own classloader to do
that, but it won't be very efficient because you'll have to scan the nested jars for
each class loaded.

Otherwise, unzip the nested jars in with your regular jar (as millerch suggested) or
extract the nested jars into the file system.
 
T

Thomas Weidenfeller

Is it possible to create a jar that contains its dependant jars so
that you can distrbute an application as a single jar?

No, this has been discussed often in the past. Search an archive of this
group for details.

/Thomas
 
A

alan

No, this has been discussed often in the past. Search an archive of this
group for details.

I figured as much.

I'd looked through the JAR documentation, didn't see this ability, but
didn't see any place that said it couldn't be done. When I ran across
custom class loaders to read nested jars, I figured it was probably not an
easy thing to do. The JNLP/Java Web Start seems to address the problem for
Swing UIs, and WARs wor Web Applications, but nothing for a library
distrubtion. Which is fine.

Thank you all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top