I'm trying to use Jena. For creating a new ontology my code is:
String SOURCE = "http://www.w3.org/2002/07/owl#";
String NS = SOURCE + "#";
OntModel ontology = ModelFactory.createOntologyModel();
ontology.read( SOURCE, "OWL/XML" );
But it gives me this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.hp.hpl.jena.util.Metadata.<clinit>(Metadata.java:26)
at com.hp.hpl.jena.JenaRuntime.<clinit>(JenaRuntime.java:25)
at com.hp.hpl.jena.rdf.model.impl.RDFReaderFImpl.<clinit>(RDFReaderFImpl.java:85)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.<clinit>(ModelCom.java:42)
at com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(ModelFactory.java:122)
at com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(ModelFactory.java:116)
at com.hp.hpl.jena.vocabulary.OWL.<clinit>(OWL.java:37)
at com.hp.hpl.jena.ontology.ProfileRegistry.<clinit>(ProfileRegistry.java:48)
at com.hp.hpl.jena.ontology.OntModelSpec.<clinit>(OntModelSpec.java:54)
What's the problem?I couldn't find any solution for it.
If you use a Jena distribution, all the jars needed are in the lib/ directory. You need them all on the classpath.
On Windows / cygwin:
javac -cp '<install dir>\lib\*;' MyClass.java
On Linux:
javac -cp '<install dir>/lib/*' MyClass.java
To run, the created .class
needs to be in your path, too:
java -cp '.:<install dir>/lib/*' MyClass
If you use maven to get Jena, the dependencies are automatically pulled in.
Your Java classpath is missing one of the jar files required by Jena. Looks like it's one of the slf4j
jars. You need to have all the jar files that come with Jena on the classpath. How to set the classpath depends on your OS and/or IDE, but Google can help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.