I'd like to use Swing in an applet but don't want to force everyone to download the Java Plug-in or the complete 2 MB swingall.jar file.

Sandip Chitale

You could run your application on you machine with '-verbose' option of the 'java' turned on. This should list all the classes loaded into your application on the STDERR. You can strip all the classes in 'java.*' packages from the list and bundle the rest into a single jar file. This should include all 'javax.*' (Swing) and your application classes. This assumes that you have forced loading of all the classes you will ever need by exercising every feature.

Compilers like 'jikes' can emit the list of classes that a particular class, directly or indirectly depends on. You could get a unique set from all your compilations and pick up the Swing and your application classes that appear in your output to build the jar file.

NOTE: If you have any dynamically loaded classes (classes loaded as follows)

Sting className = // get the class name somehow;

these classes won't appear in the list generated by the compiler. They'll still appear using the -verbose option of the java interpreter, though

There are some tools on the Web which do what you want also.

You may still run into a problem though - because the version of AWT library in the browser may be older than what the Swing library needs. And Swing is based on top of AWT.

You may want to look into the Jar indexing feature also and exploit that in a custom classloader which you use to get the classes.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact