Java web start and jars...

T

tiewknvc9

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?
 
T

Thomas Hawtin

tiewknvc9 said:
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
 
T

Thufir

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
 
A

Andrew Thompson

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.
 
T

Thomas Weidenfeller

tiewknvc9 said:
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
 

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

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top