One-JAR with JNLP/Web-Start

My Problem is: I have built the swing one-jar application(which contains boot package, main/main.jar(my application) and lib/*.jar(database jar and some external jars) and images folder). Bundling all jars into a single JAR (Source: http://www-128.ibm.com/developerworks/java/library/j-onejar/) ..

It is working fine when I double click the jar(myap.jar), but if I try to run from web start (using myApp.jnlp), It is loading boot startup package and after that...it is unable to load other jars inside a single jar...ends with :: classNotFound exception(my application package jars not loading - i.e main.jar ). I red some java forums, which they are suggesting to use dynamic jar loading mechanism from boot start-up files(URLClassLoader instead of JarClassLoader)., Can any one please help me..!

I got one-jar(bundling all jars in a single jar) solution from :http://one-jar.sourceforge.net/

My JNLP file as follows

<?xml version="1.0" encoding="utf-8"?>

<jnlp spec="1.0+" codebase="http://localhost:8080/myapp" href="uamtool.jnlp">

<information>

<title>UAM Tool Application</title>

<vendor>Fidelity International Ltd.,</vendor>

<homepage href="index.jsp"/>

<description>UAM Tool Application</description>

<description kind="short">A demo of the capabilities of the Swing Graphical User Interface.</description>

<icon href="images/logo.gif"/>

<icon kind="splash" href="images/logo.gif"/>

<offline-allowed/>

</information>

<shortcut online="true">

<desktop/>

</shortcut>

<security>

<all-permissions/>

</security>

<resources>

<j2se version="1.4+"/>

<jar href="myap.jar" main="true"/>

</resources>

<application-desc main-class="com.simontuffs.onejar.Boot"/>

</jnlp>

[2014 byte] By [Surya_Fidelitya] at [2007-11-27 0:09:15]
# 1

> My Problem is: I have built the swing one-jar application

> (which contains boot package, main/main.jar(my

> application) and lib/*.jar(database jar and some

> external jars) and images folder).

This might make some sense for a stand alone

application that you want to distribute as a single file.

It does not make sense for Web Start based apps.

One of Web Start's great advantages is that it can

optimise the download for the end user, in a number

of ways.

- If resources and Jar's are marked for 'lazy' download,

only those resources required by the end user are

downloaded (e.g. if there is a Jar for 'printing support',

and the user never needs a print, it is not downloaded)

- If any one of the Jar archives in an application is updated,

Web Start will recognise that, and only update that one

archive.

I suggest you reconsider use of 'one-jar' with Web

Start based apps., and instead investigate the best

ways that JWS can provide for efficient application

delivery.

> It is working fine when I double click the

> jar(myap.jar), but if I try to run from web

> start (using myApp.jnlp),

One jar may well be using techniques such as

copying each archive from within the main archive

to TEMP, then expanding them before adding them

to the classpath and running the app. itself.

While it might be possible to replicate that from

within a signed and fully trusted Web-Start

application, it is probably a lot more work,

and less effective, than using the approach

outlined above.

Message was edited by:

AndrewThompson64

AndrewThompson64a at 2007-7-11 16:09:10 > top of Java-index,Desktop,Deploying...
# 2

Hi AndrewThompson64,

Thanks for your suggestion, Actually my client required this one-jar feature wants to run from web start. Is there any chance of running one-jar application from web start... Is there any way i can dig this one-jar boot start-up file and change according to web start...if not why can't i run it from web start...? Could you please explain it for me... Thanks

Surya_Fidelitya at 2007-7-11 16:09:10 > top of Java-index,Desktop,Deploying...
# 3

This requirement doesn't make a lot of sense. You would be better off to provide help on an Ant target that will package the resources normally for Webstart to handle them. Web start uses its own classloader, as does One-jar, so I'm not sure if what you want is possible.Packaging everything in one jar for a Webstart deployment doesn't make sense because there is no command line launcher or messy classpath to worry about, which appears to be the main point behind One-jar.

If you must, though. It appears from the One-jar docs that your application must run the one-jar bootstrap class first. Webstart ignores the manifest file entries for classpath and main class, so you might need to specify the One-jar bootstrap jar file seprately in the JNLP file. Something like:

<resources>

<j2se version="1.4+"/>

<jar href="one-jar-boot.jar" main="true"/>

<jar href="myap.jar"/>

</resources>

<application-desc main-class="com.simontuffs.onejar.Boot"/>

I doubt if this will work, however, since many people have tried nesting jar files and no one has came up with a workable solution with Webstart that I am aware of. I hope this helps you find an answer, though.

Erik

evickroya at 2007-7-11 16:09:10 > top of Java-index,Desktop,Deploying...
# 4

> Actually my client required this one-jar feature

> wants to run from web start.

Why?

And note that your claims to the effect of

'this has to be a great strategy' are simply

incorrect - in so many ways. Web start

already has an efficient way to both deliver

applications, and update parts of an

application when archives (Jar's) are

updated. The one-jar 'solution' actually

nullifies all the hard work the designers of

web start put into making that efficient

solution work.

AndrewThompson64a at 2007-7-11 16:09:10 > top of Java-index,Desktop,Deploying...