JARs containing JARs

Discussion in 'Java' started by alan, May 18, 2005.

  1. alan

    alan Guest

    Is it possible to create a jar that contains its dependant jars so
    that you can distrbute an application as a single jar?
    alan, May 18, 2005
    1. Advertisements

  2. alan

    millerch Guest

    Why not unzip the dependant jars and create a new jar containing your
    application, and all its dependant class files?
    millerch, May 18, 2005
    1. Advertisements

  3. alan

    Steven Green Guest

    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.

    Steven Green, May 18, 2005
  4. 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.
    Lee Fesperman, May 19, 2005
  5. No, this has been discussed often in the past. Search an archive of this
    group for details.

    Thomas Weidenfeller, May 19, 2005
  6. alan

    alan Guest

    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.
    alan, May 19, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.