SAX and JNI
I'm having problems using Java classes from C. I've managed to trace the problem as far as the SAX parser, but I have no idea why there's a problem at all.
With the -verbose:jni option on, there's a message:"Unable to read from file" and then the JVM stops (crashes actually.)
I create a VM as follows:
JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs args;
JavaVMOption options[3];
int ret;
args.version = JNI_VERSION_1_4;
args.nOptions = 3;
options[0].optionString = classPath;
options[1].optionString ="-verbose:jni";
options[2].optionString ="-Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl";
args.options = options;
args.ignoreUnrecognized = JNI_TRUE;
if ((ret = JNI_CreateJavaVM(&jvm, (void **)&env, &args)) < 0){
/* error */
}
classPath is just a char* that lists all the Jars the project uses. I wrote a Java main() to test my code and when you run it with the exact same classpath, it works.
The Java code that creates and starts the SAX parser looks like:
XMLHandler handler =new XMLHandler ();
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
try{
saxParser.parse(f, handler);
}catch (java.io.IOException e){
e.printStackTrace ();
}catch (Exception e){
e.printStackTrace ();
}
Is there something about JNI that SAX stuff won't work with it?
Any help is greatly appreciated.

