Hello!
I am currently working on a java applet which is able to draw charts.
Unfortunately, the compiled jar-archive with the third party modules
(JFreeChart, JCommon, netBeans GUI library) is around 1.5MB large, so it
takes quite some time until the applet is loaded in the browser. Is
there any possibility to reduce this filesize (packaging, etc.)?
In fact, my own application is only about 30kB large but the other
libraries bring such an overhead along.
Any suggestions and hints appreciated!
Fabian
Steve W. Jackson - 08 Aug 2006 18:26 GMT
> Hello!
>
[quoted text clipped - 9 lines]
>
> Fabian
If you intend to use JFreeChart and JCommon, you don't have much choice
there. But you might want to consider learning enough GUI to skip the
requirement for the NetBeans part of that.

Signature
Steve W. Jackson
Montgomery, Alabama
Daniel Dyer - 08 Aug 2006 19:13 GMT
> Hello!
>
[quoted text clipped - 7 lines]
>
> Any suggestions and hints appreciated!
You could run the libraries through an obfuscator/shrinker such as
Proguard (http://proguard.sourceforge.net). The size reduction you can
achieve depends on your settings, but it could be quite substantial. As
well as sinking the classes that you use, you can, for example, get it to
omit all of the classes that are not used by your application.
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk
Andrew Thompson - 09 Aug 2006 01:01 GMT
..
> I am currently working on a java applet which is able to draw charts.
> Unfortunately, the compiled jar-archive with the third party modules
[quoted text clipped - 3 lines]
> In fact, my own application is only about 30kB large but the other
> libraries bring such an overhead along.
In addition to the NetBeans/obfuscation points.
Therer are a number of ways to ensure
1) something appears for your users early on, and
2) the applet appears ASAP.
In response to 1) you might
a) use a 'loader' applet to indicate loading
progress of the main applet.
b) wrap your applet in WebStart - if you specify the Jar
sizes, JWS will indicate the download progress.
In response to 2) you might
Load the minimum necessary classes to get the applet
on-screen, then start a thread to construct and show any
..graphs, whatever.
Now, that is not especially useful for applets where
it takes longer to donwload the right jar than it does to
construct the GUI. *However* you can gain that advantage
back, again if you launch using WebStart - resources
(jar files) can be specified as a 'lazy' download -
not downloaded until required.
HTH
Andrew T.
Chris Uppal - 09 Aug 2006 10:37 GMT
> I am currently working on a java applet which is able to draw charts.
> Unfortunately, the compiled jar-archive with the third party modules
> (JFreeChart, JCommon, netBeans GUI library) is around 1.5MB large, so it
> takes quite some time until the applet is loaded in the browser.
It might be worth experimenting with unpacking the JARs.
When HTTP first came out it had no way to avoid setting up a new TCP/IP
connection for each file downloaded, and that is quite an expensive operation.
So Sun (with their usual fine grasp of technical issues) decided to invent the
JAR format as a workaround -- thus downloading the entire applet in one file.
What they ignored was the fact that HTTP 1.1 introduces a better solution to
the same problem, and (as far as I know), most or all modern browsers will keep
a single (or a few) TCP/IP connections open to the server, and multiplex file
requests over that connection -- thus avoiding the setup costs, but also not
downloading unneeded files.
-- chris