ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Skeet" <jon.sk...@peramon.com>
Subject RE: Jar file loading
Date Wed, 23 May 2001 14:29:16 GMT
> Still, if anyone needs a couple of utilities to trace down 
> where a class is being loaded from, I'm happy to share. (One's even 
> defined as an ant task! ;)

I've come into this discussion late, but I thought I'd chip in one small
contribution, if people don't want to download whole full utilities - a
tiny little program knocked up for a usenet post:

public class JWhich
{
    public static void main (String [] args)
        throws Exception
    {
        for (int i=0; i < args.length; i++)
        {
            try
            {
                Class c = Class.forName (args[i]);
                String classRes = "/"+args[i].replace ('.', '/')+
                                  ".class";
                System.out.println ("Class "+args[i]+
                                    " URL: "+
                                    c.getResource (classRes));
            }
            catch (Throwable t)
            {
                System.out.println ("Unable to locate class "+
                                    args[i]);
            }
        }
    }
}

eg:

C:\>java JWhich java.util.Vector JWhich foo
Class java.util.Vector URL: 
jar:file:/C:/jdk1.3/jre/lib/rt.jar!/java/util/Vector

Hope this may be of some use.

Jon

Mime
View raw message