|
Hi ,
I have downloaded the xerces-1_2_1 from apache
site.I am reading the Java-Xml Book from Oreilly.
After extracting the xerces files I have set the classpath to <roo>/xerces.jar and <root>xercesSamples.jar. Then I have created one folder called 'practice' inside 'Samples' i.e (<root>/Xerces/Samples/practice).Now I am facing two problems. 1. I wrote SAXPerserDemo.java and saved it inside 'practice' as below: import org.xml.sax.XMLReader; public class SAXPerserDemo{
public void performDemo(String uri){ System.out.println("Parsing XML FIle :"+uri+"\n\n"); try{ XMLReader parser = (XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(); }catch(Exception e){ e.printStackTrace(); } } public static void main(String args[]){ if(args.length == 0){ System.out.println("Usage:java SAXPerserDemo [XML URI]"); System.exit(0); } String uri = args[0]; SAXPerserDemo perserDemo = new SAXPerserDemo(); perserDemo.performDemo(uri); } } In oreilly it is given : XMLReader parser = new SAXParser(); But this line does not compile in this version of Xerces.So I made the changes as XMLReader parser = (XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(); then it compiles successfully. Now what should I do to get the line XMLReader parser = new SAXParser(); compiled successfully. 2. When I copiled the file SAX2Count.java
from 'sax' to 'practice'
directory and made some changes and rename it as SAX2CountModified.java then it compiled successfully but when I gave the command java SAX2CountModified then it gave me the exception as: G:\Xerces\Samples\practice>java SAX2CountModified Exception in thread "main" java.lang.NoClassDefFoundError: SAX2CountModified (wr ong name: sax/SAX2CountModified) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:403) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10 1) at java.net.URLClassLoader.defineClass(URLClassLoader.java:248) at java.net.URLClassLoader.access$1(URLClassLoader.java:216) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:191) at java.lang.ClassLoader.loadClass(ClassLoader.java:280) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275) at java.lang.ClassLoader.loadClass(ClassLoader.java:237) *** Please inform me what should I do to get it
run.
Waiting for your mail. With Regards Rajarshi Ghosh |
- RE: Problem with Xerces-1_2_1(Java) Rajarshi Ghosh
- RE: Problem with Xerces-1_2_1(Java) Swanson, Brion
- Re: Problem with Xerces-1_2_1(Java) Rajarshi Ghosh
- Re: Problem with Xerces-1_2_1(Java) Rajarshi Ghosh
