Java web start and jars...

Discussion in 'Java' started by tiewknvc9, Sep 21, 2006.

  1. tiewknvc9

    tiewknvc9 Guest

    I have a couple of questions about this, and Im hoping a couple of you
    can share your thoughts.

    With java web start, if I were to pack everything into a single jar and
    have someone download it. Then update a single class file within that
    jar, is the whole jar downloaded onto their computer for the next
    update? Or is the single class file downloaded to their machine for
    the update?

    If the answer is that the entire jar file is downloaded... then....

    can java webstart support multiple jar files as a single application?
    meaning, if I were to supply 3 jar files (one with the graphics, one
    with library jars/zips, and one with my classes), how would I go about
    loading the resources from the seperated out jars? Or would it seem
    seemless as long as the classpath is set up properly?
    tiewknvc9, Sep 21, 2006
    #1
    1. Advertising

  2. tiewknvc9 wrote:
    >
    > With java web start, if I were to pack everything into a single jar and
    > have someone download it. Then update a single class file within that
    > jar, is the whole jar downloaded onto their computer for the next
    > update? Or is the single class file downloaded to their machine for
    > the update?


    If you just dump it on a web server, then yes. However, there is a
    jardiff format for patches. IIRC, there's a provided servlet that
    handles the serving up the right version.

    > can java webstart support multiple jar files as a single application?
    > meaning, if I were to supply 3 jar files (one with the graphics, one
    > with library jars/zips, and one with my classes), how would I go about
    > loading the resources from the seperated out jars? Or would it seem
    > seemless as long as the classpath is set up properly?


    Yes. All the classes from all the application jars are loaded by the
    same class loader.

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
    Thomas Hawtin, Sep 21, 2006
    #2
    1. Advertising

  3. tiewknvc9

    Thufir Guest

    On Thu, 21 Sep 2006 14:10:07 -0700, tiewknvc9 wrote:

    > I have a couple of questions about this, and Im hoping a couple of you
    > can share your thoughts.
    >
    > With java web start, if I were to pack everything into a single jar and
    > have someone download it. Then update a single class file within that
    > jar, is the whole jar downloaded onto their computer for the next
    > update? Or is the single class file downloaded to their machine for
    > the update?
    >
    > If the answer is that the entire jar file is downloaded... then....
    >
    > can java webstart support multiple jar files as a single application?
    > meaning, if I were to supply 3 jar files (one with the graphics, one
    > with library jars/zips, and one with my classes), how would I go about
    > loading the resources from the seperated out jars? Or would it seem
    > seemless as long as the classpath is set up properly?


    What do you mean by "everything"? For instance, if the app uses a third
    party jar file, which you distribute, then it's already a minimum of two
    jar files which JWS is distributing.


    -Thufir
    Thufir, Sep 22, 2006
    #3
  4. tiewknvc9 wrote:

    Thomas seems to have answered the core of your technical
    question, but I will just point out that..

    > ...if I were to supply 3 jar files (one with the graphics, one
    > with library jars/zips, ..


    ...if you have (for example) ftp.jar, format.jar and properties.zip,
    *each* of these will need to be added separately to the application's
    classpath.

    If you bundle *those* three files up in an 'alllibs.jar', the
    classloader will fail to find resources in any of the three
    libraries. Java classloaders are not set up to deal with
    'archives within archives'.

    Alternately, you might
    a) extract the contents of each archive and put the entire
    result into a single archive (a very non-optimal approach), or..
    b) reference each of the library files in a single JNLP file
    that is marked as an extension/component, then have other
    JNLP files refer to the extension JNLP.

    Option b) is the best because it allows you to refer to
    the resources ..
    - 'on mass', where needed, via the extension JNLP
    - separately, in the case where less than the entire
    set is required.
    - in other JNLP's (both extension and application/applet).

    HTH

    Andrew T.
    Andrew Thompson, Sep 22, 2006
    #4
  5. Andrew Thompson a écrit :

    >> ...if I were to supply 3 jar files (one with the graphics, one
    >> with library jars/zips, ..

    >
    > Alternately, you might
    > a) extract the contents of each archive and put the entire
    > result into a single archive (a very non-optimal approach), or..



    You can use Fat JAR eclipse extension :
    http://fjep.sourceforge.net/


    --
    Nicolas Moreau
    Nicolas Moreau, Sep 22, 2006
    #5
  6. tiewknvc9 wrote:
    > With java web start, if I were to pack everything into a single jar and
    > have someone download it.


    Which is not a clever idea, particular if you start to repack 3rd party
    jars (and it might even violate the 3rd party licenses). Packing
    everything in one big jar is typically only attempted by people who
    don't want to use web start and don't get their classpath settings
    right in the main jar.

    But that's not the issue here.

    > Then update a single class file within that
    > jar, is the whole jar downloaded onto their computer for the next
    > update?


    Webstart has a barely documented only-send-the-differences feature:
    jardiff files. Your best bet is to use Sun's JnlpDownloadServlet on the
    server to generate and provide them, since

    http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/downloadservletguide.html

    is the only official mentioning of jardiff in the JDK documentations I
    am aware of.

    Interestingly Sun delivers the source code of a stand-alone tool for
    creating and applying jardiffs with each JDK (as part of the mentioned
    servlet source code), but doesn't lose a word about it. Go into your JDK
    installation directory and then:

    ../sample/jnlp/servlet/ for a prebuild version:

    java -jar jardiff.jar
    JarDiff: [-nonminimal (for backward compatibility with 1.0.1/1.0]
    [-creatediff | -applydiff] [-output file] old.jar new.jar

    And

    ../sample/jnlp/servlet/src/classes/jnlp/sample/jardiff/

    for the sourcecode.

    The tool can not only create the diffs, but also apply (patch) an
    existing jar.


    /Thomas
    --
    The comp.lang.java.gui FAQ:
    http://gd.tuwien.ac.at/faqs/faqs-hierarchy/comp/comp.lang.java.gui/
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    Thomas Weidenfeller, Sep 22, 2006
    #6
  7. tiewknvc9

    Thufir Guest

    On Fri, 22 Sep 2006 10:35:00 +0200, Nicolas Moreau wrote:

    > Andrew Thompson a écrit :
    >
    >>> ...if I were to supply 3 jar files (one with the graphics, one
    >>> with library jars/zips, ..

    >>
    >> Alternately, you might
    >> a) extract the contents of each archive and put the entire
    >> result into a single archive (a very non-optimal approach), or..

    >
    >
    > You can use Fat JAR eclipse extension :
    > http://fjep.sourceforge.net/



    Interesting, thanks for the link. Is it just on my end, or is the
    threading for this topic wonky?


    -Thufir
    Thufir, Sep 23, 2006
    #7
  8. Thufir wrote:
    > On Fri, 22 Sep 2006 10:35:00 +0200, Nicolas Moreau wrote:
    >
    > > Andrew Thompson a écrit :
    > >
    > >>> ...if I were to supply 3 jar files (one with the graphics, one
    > >>> with library jars/zips, ..
    > >>
    > >> Alternately, you might
    > >> a) extract the contents of each archive and put the entire
    > >> result into a single archive (a very non-optimal approach), or..

    > >
    > >
    > > You can use Fat JAR eclipse extension :
    > > http://fjep.sourceforge.net/

    >
    >
    > Interesting, thanks for the link. Is it just on my end, or is the
    > threading for this topic wonky?


    It seems logical, viewing through GG*, e.g.
    <http://groups.google.com/group/comp.lang.java.programmer/msg/261eae38ae8e3bc9>

    * 'Google Groups' - the archive of the group as represented
    by the big G..

    Andrew T.
    Andrew Thompson, Sep 23, 2006
    #8
  9. tiewknvc9

    Thufir Guest

    On Sat, 23 Sep 2006 01:29:35 -0700, Andrew Thompson wrote:

    > Thufir wrote:
    >> On Fri, 22 Sep 2006 10:35:00 +0200, Nicolas Moreau wrote:
    >>
    >> > Andrew Thompson a écrit :
    >> >
    >> >>> ...if I were to supply 3 jar files (one with the graphics, one
    >> >>> with library jars/zips, ..
    >> >>
    >> >> Alternately, you might
    >> >> a) extract the contents of each archive and put the entire
    >> >> result into a single archive (a very non-optimal approach), or..
    >> >
    >> >
    >> > You can use Fat JAR eclipse extension :
    >> > http://fjep.sourceforge.net/

    >>
    >>
    >> Interesting, thanks for the link. Is it just on my end, or is the
    >> threading for this topic wonky?

    >
    > It seems logical, viewing through GG*, e.g.
    > <http://groups.google.com/group/comp.lang.java.programmer/msg/261eae38ae8e3bc9>
    >
    > * 'Google Groups' - the archive of the group as represented
    > by the big G..
    >
    > Andrew T.



    Perhaps it's on my end, then. I'm using leafnode and pan. However, I'm
    only aware of a single thread, this one, being fragmented. Off topic,
    anyhow.


    -Thufir
    Thufir, Sep 23, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ike
    Replies:
    6
    Views:
    1,039
    Andrew Thompson
    Sep 24, 2004
  2. Replies:
    5
    Views:
    9,005
  3. Replies:
    6
    Views:
    5,498
    Smalltalker
    Jun 14, 2005
  4. JavaEnquirer
    Replies:
    2
    Views:
    503
    JavaEnquirer
    Feb 22, 2006
  5. Ulf Meinhardt
    Replies:
    2
    Views:
    1,387
Loading...

Share This Page