I imported Jena package and tried to use the functions in this
package. The program is as follow:
import java.io.*;
import com.hp.hpl.jena.*;
import java.util.*;
import com.hp.hpl.jena.util.*;
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.util.iterator.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelFactory;
public class getKB {
OntModel m;
/** Creates a new instance of getkb */
public getKB() {
try{
m = ModelFactory.createOntologyModel();
FileInputStream fis = new FileInputStream("kb.owl");
m.read(fis, null);
System.out.println("read success");
fis.close();
}catch (Exception e) {
System.out.println(e.getMessage());
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("hello");
getKB kb = new getKB();
//kb.abclass();
}
}
And I complied as follow:
javac -classpath antlr.jar;concurrent.jar;icu4j.jar;jakarta-oro-
2.0.5.jar;jena.jar;junit.jar;log4j-1.2.7.jar;rdf-api-2001-01-
19.jar;xercesImpl.jar;xmlParserAPIs.jar getKB.java
java getKB
It is OK to compile the program. But when I executed it, it said:
hello
Exception in thread "main" java.lang.NoClassDefFoundError:
com/hp/hpl/jena/rdf/model/ModelFactory
I think the problem is m = ModelFactory.createOntologyModel(), but I
am sure I have included the package in it at runtime. I really have
no idea. Could anyone help me?