[jdom-interest] problems with classpath

Patrick Dowler Patrick.Dowler at nrc.ca
Fri Oct 27 11:53:34 PDT 2000

For all those people who have problems with classpath, here is a simple 
prog to help diagnose it. Usage is as follows:

java [-classpath if you need it] WhichClass [full class name]

If you don't provide a classname, you find java.lang.String by default.
Obviously this won't work if you are doing some ClassLoader magic
and it may not help you in a J2EE/EJB situation. It does help to
remember that you stuck something into the JRE's ext directory.


Patrick Dowler
Canadian Astronomy Data Centre

import java.net.URL;
class WhichClass
        public static void main(String[] args)
                String targetClass = "java.lang.String";
                if ( args.length > 0 )
                        targetClass = args[0];
                        System.out.println("found '"+targetClass+"'");
                catch(ClassNotFoundException ex)
                        System.out.println("failed to find '"+targetClass+"'");
                URL u = ClassLoader.getSystemResource(toPath(targetClass));
                System.out.println("url: " + u);
        private static String toPath(String className)
                StringBuffer sb = new StringBuffer(className);
                for (int i=0; i<sb.length(); i++)
                        if ( sb.charAt(i) == '.' )
                return sb.toString();

More information about the jdom-interest mailing list