Skip to main content

problem with class not found

3 replies [Last post]
arckjmaster
Offline
Joined: 2007-04-18
Points: 0

Hi, just wondering if there's a reason that I'm seeing this problem?

There is no compile problem, but when I execute the .class file there is problem

>java ParseByEvent
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream/XMLInputFactory

My source code:

import java.io.*;
import java.util.Iterator;
import javax.xml.stream.*;
import javax.xml.stream.events.*;
import javax.xml.namespace.*;
import javax.xml.stream.util.*;

public class ParseByEvent {

public static void main(String[] args) {
try {

System.setProperty("javax.xml.stream.XMLInputFactory","javax.xml.stream.XMLInputFactory");

XMLInputFactory factory = XMLInputFactory.newInstance();
System.out.println("FACTORY: " + factory);

} catch (Exception e) {

}
}

}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joehw
Offline
Joined: 2004-12-15
Points: 0

Oops, sorry. I see you've downloaded JAXP 1.4.1.


Your code should work if you remove the line that sets XMLInputFactory property to itself. This property is used to specify specific XMLInputFactory implementation. That is, if you want to use a StAX implementation other than the one in JAXP. Thx.

arckjmaster
Offline
Joined: 2007-04-18
Points: 0

I don't think stax is working at all with jdk1.5.0_06, even when I specify the classpath of the jar files none of the stax library works

joehw
Offline
Joined: 2004-12-15
Points: 0

No, it doesn't. StAX was the major addition to JAXP 1.4/JDK6. Refer to the JAXP 1.4 Release Notes.



Two options to make StAX work:

1. Get SJSXP directly from here. This is what's added to JAXP 1.4.



2. Update to JAXP 1.4.



Hope it helps.