Joscha said:
hi again,
the problem is that I will *not* know the name of the jar file. And I
will *not* know the name of any ressource in that jar-File.
So you know nothing.
So
getClass().getResource('whatever/blue.gif').toString().substring(0,name.indexOf('!')
will not work, because I don't have no 'blue.gif'.
So you have no means to find out something.
You have no file name, but you want to iterate over the contents of a
file. It must be that specific file, for which you haven't specified why
it is special, and how that particular file is different from all the
other jar files in your class path. All you have said is that there is a
jar which magically ended up in your class path, and you want to iterate
over its contents. Because, aehm, because you want it that way.
Most obvious conclusion: You have zero information to work with,
therefor you need a miracle or a crystal ball.
I strongly suggest you rethink your problem and you consider not to use
the class path for what you want to achieve (whatever it is that you
want to achieve, you haven't bothered to tell us).
If you want to mess with the class path (what is it that makes the class
path so attractive to mess with?), at least try to stack the cards in
your favor. E.g. place some marker file in the jar, like
"THIS-IS-MY-VERY-IMPORTANT-JAR". And use getResource() as it has been
explained to you several times to find the URL of that marker file.
Or use a fixed, well defined file name. Then pray that your system class
loader is a subclass of URLClassLoader. Get the system class loader, try
to cast it to a URLClassLoader. If successful, use getURLs() to get the
search path of the class loader. Examine each URL in that array if it
ends in your file name.
/Thomas