• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help for a XML demo program  RSS feed

 
James Zhang
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to play with the SAX and DOM with a standard demo program downloaded from a XML tutorial. However, every time I always got the exception java.lang.NoClassDefFoundError for org.xml.sax.helpers.DefaultHandler if I used the lib file from Java Web Services Developer Pack 1.2 from Sun installed on my machine. I also got JDK1.4 from WebLogic on my machine, but then the error when running the program becomes java.net.UnknowHostException in java.sun.com (why the net package is used here?).
I guess the problem is that I don't have the correct jar file. Does anybody know which jar files are needed for SAX and DOM and where to get them?
Thanks!
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This shd be basically a classpath problem.
If you are working from a command prompt, please check whether ur current classpath is configured to include the set of jar files provided by JWSDK pack.
Normally, to run SAX/DOM examples you just XML parser like Xerces ( http://xml.apache.org/xerces2-j/install.html ) or crimson etc., I guess JWSDK is shipped with xerces.
if you just want to try sax-dom demo examples you can try Xerces http://xml.apache.org/xerces2-j/install.html from Apache. To run the example you just need xercesImpl.jar and xml-apis.jar.
I guess one of the moderator will move this thread XML forum here.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 1.4 version of Java incorporates basic XML parser functionality. There have been lots of changes in API over the last few years, errors you are getting sounds like you may have a mis-match between the tutorial and various jar files and classpaths on your system.
The org.xml.sax.helpers.DefaultHandler interface is new and included in the SDK 1.4 - you should be able to compile that with just the SDK and without any other XML related jar in your classpath.
Bill
 
James Zhang
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply, Anbae Sivam and Bill. I have figured out the problem -- The XML file I was testing refers to a standard DTD file. When I removed the line, everything was fine (with jar files provided by Weblogic). Anyway, I really appreciate your help!
--Jian
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!