AW: [jdom-interest] Newbie classpath problem

Falk Fraikin fraikin at informatik.tu-darmstadt.de
Mon Mar 19 23:55:34 PST 2001


Hi Richard,

a while ago there was a very helpful post by Patrick Dowler in this list. It
provided the following class that can be used to find out from where you are
actually loading a certain class. So it should help you to validate your
classpath.

import java.net.URL;
class WhichClass{
   public static void main(String[] args){
      String targetClass = "java.lang.String";
      if ( args.length > 0 )
         targetClass = args[0];
      try{
         Class.forName(targetClass);
         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) == '.' )
            sb.setCharAt(i,'/');
      sb.append(".class");
      return sb.toString();
   }
}

After you compiled that class, usage is as follows:
java [-cp if-you-need-it] WhichClass [name-of-the-class]

So you can try things like:
java WhichClass org.xml.sax.SAXException
or
java WhichClass org.xml.sax.Attributes
to find out if you have any unwanted jar files (and where). I never had this
problem so I don't know which classes are really sensible to search for
(classes which are included in unwanted versions of a parser)...

Good luck,

Falk

-----Ursprungliche Nachricht-----
Von: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]Im Auftrag von RM Barry
Gesendet: Montag, 19. Marz 2001 08:04
An: jdom-interest at jdom.org
Betreff: [jdom-interest] Newbie classpath problem


I quote from the FAQ:

I tried to use JDOM and get an error like this:
java.lang.NoSuchMethodError
 or
  java.lang.NoClassDefFoundError:
org/xml/sax/SAXNotRecognizedException
What's wrong?
You need to ensure that the xerces.jar file supplied with the
JDOM download  is in your classpath before any other XML classes,
 such as those that come with  JAXP or Crimson. These other XML
libraries, as well as older versions of Apache  Xerces, support DOM
Level 1 and SAX 1.0, not the required DOM Level 2 and  SAX 2.0.
The result is an exception being thrown. Check your classpath, and
try  again. If the classpath looks OK, the problematic JAR might also
 be hiding in the  system's standard extension directory
(jre\lib\ext).
I'm having this problem, and I tried to solve it by putting the
xerces.jar file as  the first entry of my classpath, but no joy.   I'm
using Forte4j community  edition as IDE, and this is the classpath I
 specify for the compiler:

C:\devel\jdom-
b6\lib\xerces.jar;C:\DEVEL\FORTE4J\lib\patches\openide-
compat.jar;C:\DEVEL\FORTE4J\lib\developer.jar;C:\DEVEL\FO
 RTE4J\lib\o
penide.jar;C:\DEVEL\FORTE4J\lib\updater.jar;C:\DEVEL\FORT
 E4J\lib\ext\
AbsoluteLayout.jar;C:\DEVEL\FORTE4J\lib\ext\icebrowserlitebe
an.jar;C:\DE VEL\FORTE4J\lib\ext\javac.jar;C:\devel\jdom-
b6\build\jdom.jar;C:\DEVEL\FORTE4J\lib\ext\jaxp.jar;C:\DEVEL
 \FORTE4J\
lib\ext\jh.jar;C:\DEVEL\FORTE4J\lib\ext\parser.jar;C:\DEVEL\F
ORTE4J\lib\
ext\regexp.jar;C:\DEVEL\FORTE4J\lib\ext\servlet.jar;C:\JDK1.3\l
 ib\dt.jar;C:\ JDK1.3\lib\tools.jar;C:\devel;C:\devel\xmlrpc-
java;C:\devel\xmlrpc-
java.zip;C:\devel\HTTPClient.zip;C:\devel\xmlrpc-
java\lib\openxml- 1.2.jar;C:\devel\xmlrpc-java\lib\xmlrpc-
applet.jar;C:\devel\xmlrpc- java\lib\xmlrpc.jar;C:\devel\jdom-
b6\lib\collections.jar;C:\devel\jdom- b6\lib\ant.jar

As you can see the xerces.jar file is the first entry.

Can anyone help me on this?  I'm a novice programmer so even
obvious help  will be helpfull.
Thanks,
Richard Barry
------- End of forwarded message -------
-----------------------------
Richard Barry
MSc.Ing.
Universiteit van Stellenbosch
Tel 072-2553055 (sel)
    021-8839482 (huis)
    021-8084329 (lab)
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com




More information about the jdom-interest mailing list