J
jeanlutrin
I've got a question regarding how to "dynamically change
the classpath" ?
I've already written some (simple) custom ClassLoaders,
to help... loading classes.
This time, I need to do something and I think I need to
use a custom ClassLoader but I'm really not sure. And
if I need to use/write one, I don't know of to go about
it.
Here's my problem:
- I've got several .jars that my application needs and I
have to keep these files as separated jars.
- I cannot be sure of the exact location of these jars, so
I cannot add them to the main jar's MANIFEST.MF's Class-Path:.
- At runtime, I will have a way to know where those jars are
located.
How can I tell the application "if you don't find a class, go
look into those jars"?
I've read several articles/webpages and read code sample, but
I don't get it.
I know how to load a certain class from a .jar, but not how
to tell the application "if you don't find a class then look
into xxx.jar and yyy.jar and zzz.jar before throwing a
ClassDefNotFoundError".
So I think I need to use a custom ClassLoader (an URLClassLoader?),
but how...
Thanks in advance for any help,
Jean
the classpath" ?
I've already written some (simple) custom ClassLoaders,
to help... loading classes.
This time, I need to do something and I think I need to
use a custom ClassLoader but I'm really not sure. And
if I need to use/write one, I don't know of to go about
it.
Here's my problem:
- I've got several .jars that my application needs and I
have to keep these files as separated jars.
- I cannot be sure of the exact location of these jars, so
I cannot add them to the main jar's MANIFEST.MF's Class-Path:.
- At runtime, I will have a way to know where those jars are
located.
How can I tell the application "if you don't find a class, go
look into those jars"?
I've read several articles/webpages and read code sample, but
I don't get it.
I know how to load a certain class from a .jar, but not how
to tell the application "if you don't find a class then look
into xxx.jar and yyy.jar and zzz.jar before throwing a
ClassDefNotFoundError".
Why would you ever want a custom ClassLoader?
...
They let you dynamically change the classpath.
...
So I think I need to use a custom ClassLoader (an URLClassLoader?),
but how...
Thanks in advance for any help,
Jean