K
Karsten Wutzke
Hi all!
I want to bundle my app in one JAR file. In the lib sub dir of the
JAR, there should be all JAR's that the application depends on, here
bcel-5.2.jar (plus several others).
Since adding the JAR's to the manifest's Class-Path entry didn't work,
I tried my luck with a URLClassLoader. The code itself is too easy. I
have no real idea of how to tell the runtime when and how to use that
class loader. I read the class loader docs which explained the
delegation model.
So I did:
URL urlLib1 = RuntimeConfig.class.getResource("/lib/bcel-5.2.jar");
URLClassLoader cllLibs = new URLClassLoader(new URL[]{urlLib1});
I expected the class loader to become a child of the bootstrap class
loader.
The problem is: I don't really know where to put the above code.
Currently it is in my "config" class. However, the class loader
doesn't seem to be put into the delegation hierarchy, otherwise the
classloader would find the classes from the bcel JAR. I checked the
URL and JAR location inside my JAR, they seem to be correct.
As soon as one of the classes get referenced, here
org.apache.bcel.generic.Type, the (main) thread stops with a
NoClassDefFoundException.
Does anyone know what I am doing wrong? How do I make it work?
TIA
Karsten
I want to bundle my app in one JAR file. In the lib sub dir of the
JAR, there should be all JAR's that the application depends on, here
bcel-5.2.jar (plus several others).
Since adding the JAR's to the manifest's Class-Path entry didn't work,
I tried my luck with a URLClassLoader. The code itself is too easy. I
have no real idea of how to tell the runtime when and how to use that
class loader. I read the class loader docs which explained the
delegation model.
So I did:
URL urlLib1 = RuntimeConfig.class.getResource("/lib/bcel-5.2.jar");
URLClassLoader cllLibs = new URLClassLoader(new URL[]{urlLib1});
I expected the class loader to become a child of the bootstrap class
loader.
The problem is: I don't really know where to put the above code.
Currently it is in my "config" class. However, the class loader
doesn't seem to be put into the delegation hierarchy, otherwise the
classloader would find the classes from the bcel JAR. I checked the
URL and JAR location inside my JAR, they seem to be correct.
As soon as one of the classes get referenced, here
org.apache.bcel.generic.Type, the (main) thread stops with a
NoClassDefFoundException.
Does anyone know what I am doing wrong? How do I make it work?
TIA
Karsten