K
Karsten Wutzke
Hello,
my classpath consists of several entries: the first entry is either
the JAR that the application was started from or (when run from the
local dev tree) the classes build dir plus some others for images,
language packs etc. Both (Ant) run configs share ~5 libraries for the
application code, plus ~40 optional look and feel JARs.
I want to find specific resources now. Some look and feels come with
so-called themes, but there's no standard way how these are delivered:
1. Some JARs include them as some custom file format inside the JAR
2. Some offer special classes
3. Some don't include theme files at all, they have to be loaded from
the local user's disk somewhere.
#3 is easy by listing files in some search dir. #2 is even easier,
because Class.forName can handle it.
My problem is with #1. Usually each look and feel comes with files
("*.theme") placed in a specific sub dir, like "themes".
How do I find these files when the JAR was loaded via the classpath?
Since every look and feel comes at least with its own *LookAndFeel
class, Class.forName tells me the class was found and loaded, but when
trying to use that class' .getResource("/") for getting an URL to that
JAR to open a URL connection, the first classpath's entry URL is
returned, so finding the theme files becomes impossible.
How do I find the JAR file of a class that was loaded? Do I have to
split the classpath string into its parts, and iterate over each JAR
entry or just try some specific JARs?
Are there any straightforward ways to do what I need?
TIA
Karsten
my classpath consists of several entries: the first entry is either
the JAR that the application was started from or (when run from the
local dev tree) the classes build dir plus some others for images,
language packs etc. Both (Ant) run configs share ~5 libraries for the
application code, plus ~40 optional look and feel JARs.
I want to find specific resources now. Some look and feels come with
so-called themes, but there's no standard way how these are delivered:
1. Some JARs include them as some custom file format inside the JAR
2. Some offer special classes
3. Some don't include theme files at all, they have to be loaded from
the local user's disk somewhere.
#3 is easy by listing files in some search dir. #2 is even easier,
because Class.forName can handle it.
My problem is with #1. Usually each look and feel comes with files
("*.theme") placed in a specific sub dir, like "themes".
How do I find these files when the JAR was loaded via the classpath?
Since every look and feel comes at least with its own *LookAndFeel
class, Class.forName tells me the class was found and loaded, but when
trying to use that class' .getResource("/") for getting an URL to that
JAR to open a URL connection, the first classpath's entry URL is
returned, so finding the theme files becomes impossible.
How do I find the JAR file of a class that was loaded? Do I have to
split the classpath string into its parts, and iterate over each JAR
entry or just try some specific JARs?
Are there any straightforward ways to do what I need?
TIA
Karsten