Stefan Bodewig wrote:
On Mon, 17 Feb 2003, Norman Walsh <[EMAIL PROTECTED]> wrote:
If URL starts with "jar:file:", the jar's name is after that prefix.
If it starts with "file:", you are looking at a directory.  In JDK 1.1
it will start with "zip:" for jars IIRC and you are out of luck when
it comes to the file name as Java uses some internal counter instead
of the name in the URL.

I'm not sure about jars loaded from the network, but this snippet here

            if (location.startsWith("jar")) {
                url = ((java.net.JarURLConnection) 
url.openConnection()).getJarFileURL();
                location = url.toString();
            }

stolen from Ant which has stolen it from Axis IIUC seems to be a more
general solution for JDK >= 1.2.

I do not think that this is a good way to do things because it assumes too much about the classloader. In particular, I know that it doesn't work in NetBeans because NetBeans has a complex classloader system that uses some URL scheme "nbres://" or similar. So, any code (e.g. the <antlr> Ant task) that uses [if (location.startsWith("jar"))] fails.


- Brian



Reply via email to