From: Oti <oh...@ya...> - 2004-04-15 21:13:52
|
--- Shih-Chieh Lin <shi...@ho...> wrote: > Hi, everyone, I'm new to Jython. > Stated below is the situation I encouter when I import a java class > ( ) in Jython which imports the archive file "xerces.jar": > > // the Java Class > import org.w3c.dom.*; > import org.apache.xerces.parsers.DOMParser; > > public class XMLDataReader > { ...... > } > // > When I import this Java Class in Jython, Noghing goes wrong even > when I new the object of the class XMLDataReader. > But when I use the class' member function, there's an error message > that says: > > "java.lang.NoClassdefFoundError: > java.lang.NoClassDefFounError: org/apache/xerces/parsers/DOMParser" > > I've set the classpath but it didn't solve the problem. I'm > wondering if it's the problem for Jython identifying *.jar file when > wrapping a java class > that uses the *.jar file? Hi, it works for me (in a win cmd shell). First I set the CLASSPATH to contain xerces.jar and another jar containing the w3c classes, and then i import the DOMParser C:\jython>set CLASSPATH=c:/workspace/external/lib/xerces.jar C:\jython>set CLASSPATH=%CLASSPATH%;c:/workspace/external/lib /xml-apis.jar C:\jython>jython.bat Jython 2.1 on java1.3.1_06 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> from org.w3c.dom import CharacterData >>> from org.apache.xerces.parsers import DOMParser >>> DOMParser <jclass org.apache.xerces.parsers.DOMParser at 3308600> >>> by the way: >>> import org.w3c.dom.* Traceback (innermost last): (no code object) at line 0 File "<console>", line 1 import org.w3c.dom.* ^ SyntaxError: invalid syntax >>> Hope to have helped - best wishes, Oti. |