File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Problem with Java+XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem with Java+XML" Watch "Problem with Java+XML" New topic

Problem with Java+XML


Joined: Oct 30, 2000
Posts: 8
I have jdk1.2.2. I am compiling a small java program with embedded XML document. The program is as follows:
import org.xml.sax.*;
public class BookCounter extends HandlerBase
private int count = 0;

public void countBooks() throws Exception
Parser p=new com.sun.xml.parser.ValidatingParser();
public static void main(String args[]) throws Exception
(new BookCounter()).countBooks();

public void startElement(String name,AttributeList atts) throws SAXException
if (name.equals("book"))
public void endDocument() throws SAXException
System.out.println("there are "+count+ "books");
During compilation it gives the error: Class com.sun.xml.parser.ValidatingParser not found.
Parser p=new com.sun.xml.parser.ValidatingParser();
I am using kawa editor.
Please lemme know how to solve this. If there is any problem with class path please give the full steps to set up my classpath appropriately.
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
You need to download JAXP1.1 from sun at and include the jaxp.jar and parser.jar in your classpath.
Hope this helps

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD

Joined: Oct 30, 2000
Posts: 8
I have downloaded JAXP1.1 but where do I find parser.jar. It did not come along with the download:-(
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13024
If that was really the code, you only import one package:
import org.xml.sax.*;
Naturally you get this error.
Class com.sun.xml.parser.ValidatingParser not found.

prabhu palanisamy

Joined: Oct 30, 2000
Posts: 27
hi vids,
i think the problem is with setting the classpath.
in kawa goto classpath and set a new classpath to
xml.jar,give the correct path.i hope you use projectX sun parser.
if u use Xerces parser,then set the path to xerces.jar.
the problem is not with the code.
I agree. Here's the link:
subject: Problem with Java+XML
It's not a secret anymore!