K
Karsten Wutzke
Hi all!
I was wondering what would be the "best" approach to achieve class
loading flexibility in the case of
a) Running the application/applet via the local class files from the
development tree
b) Running the application/applet via a *single* JAR file?
First have a look at the dev tree
<root>
+- bin
+- images
+- lang
+- lib
| +- bcel.jar
| +- forms.jar
| +- ...
+- src
|- ....
Considering the cases:
a) When launching from local classes in dev tree, all ./lib/*.jar
files can be put on the classpath. Class loading can be performed by
the system class loader (desired).
b) When launching the single JAR file, there are basically two
approaches (affects the packaged JAR)
1. Write a custom class loader that somehow finds JAR's inside the
JAR's and loads classes from there. Disadvantage here is, that I have
to either set the so-called "libraries class loader" for any class
using a library class (to find those classes) OR I have to set my
library class loader to load *ALL* app classes system-wide (e.g. load
my main Controller class via the custom class loader, so subsequent
class loading is deferred to the custom class loader). The advantage
is, I can leave the JAR's as they are, where they are and package the
files.
2. Put *extracted* 3rd party libraries into the distribution JAR file
so that all classes run concurrently (next to the application specfic
code). All classes are always found by the system class loader and
avoids a custom class loader (and class loader headaches, which I
currently have).
The question here is: Is it legit to put extracted 3rd party JAR's
into my packaged JAR, libraries like BCEL or JGoodies for example?
Can anyone make some recommendations on what would be probably be the
best overall approach?
Karsten
I was wondering what would be the "best" approach to achieve class
loading flexibility in the case of
a) Running the application/applet via the local class files from the
development tree
b) Running the application/applet via a *single* JAR file?
First have a look at the dev tree
<root>
+- bin
+- images
+- lang
+- lib
| +- bcel.jar
| +- forms.jar
| +- ...
+- src
|- ....
Considering the cases:
a) When launching from local classes in dev tree, all ./lib/*.jar
files can be put on the classpath. Class loading can be performed by
the system class loader (desired).
b) When launching the single JAR file, there are basically two
approaches (affects the packaged JAR)
1. Write a custom class loader that somehow finds JAR's inside the
JAR's and loads classes from there. Disadvantage here is, that I have
to either set the so-called "libraries class loader" for any class
using a library class (to find those classes) OR I have to set my
library class loader to load *ALL* app classes system-wide (e.g. load
my main Controller class via the custom class loader, so subsequent
class loading is deferred to the custom class loader). The advantage
is, I can leave the JAR's as they are, where they are and package the
files.
2. Put *extracted* 3rd party libraries into the distribution JAR file
so that all classes run concurrently (next to the application specfic
code). All classes are always found by the system class loader and
avoids a custom class loader (and class loader headaches, which I
currently have).
The question here is: Is it legit to put extracted 3rd party JAR's
into my packaged JAR, libraries like BCEL or JGoodies for example?
Can anyone make some recommendations on what would be probably be the
best overall approach?
Karsten