Compiling the stand alone class called Manager gives me a ClassNotFoundException. The code is:
public class Manager {
public static void main(String[] args) {
try {
File file = new File("/Users/pjotr/Documents/example.ttl");
// Now load the ontology.
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file);
//Class c = manager.getClass();
Class c = OWLManager.class;
//Class c = OWLOntologyManagerFactory.class;
//Class c = OWLDataFactory.class;
System.out.println("CLASS = "+c);
Method[] m = c.getDeclaredMethods();
for (Method e : m) {
System.out.println(e);
}
} catch (Exception e) {
e.printStackTrace();
}
}
The command to compile and execute from the command line is:
javac -proc:full -cp $CLASSPATH Manager.java ; java -cp $CLASSPATH Manager
The $CLASSPATH is:
/Users/peter/Downloads/bundles/*:.
where de directory bundle points to all the jar files in the directory bundle of the application Protege 5.6.0 and the point obviously is needed to run the Manager.class itself.
I read in the documentation that Protege 5.6.0 internally uses OLWAPI version 4.5.
The ClassNotFoundException appears on “OWLManager.createOWLOntologyManager()”.
If I remove the two lines
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file);
then the java.lang.reflect part tells me the class OWLManager is present:
CLASS = class org.semanticweb.owlapi.apibinding.OWLManager
public org.semanticweb.owlapi.model.OWLOntologyManager org.semanticweb.owlapi.apibinding.OWLManager.get()
public java.lang.Object org.semanticweb.owlapi.apibinding.OWLManager.get()
private static org.semanticweb.owlapi.utilities.Injector org.semanticweb.owlapi.apibinding.OWLManager.configure(org.semanticweb.owlapi.utilities.Injector)
public static org.semanticweb.owlapi.model.OWLDataFactory org.semanticweb.owlapi.apibinding.OWLManager.getOWLDataFactory()
public static org.semanticweb.owlapi.model.OWLDataFactory org.semanticweb.owlapi.apibinding.OWLManager.getOWLDataFactory(org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration)
public static org.semanticweb.owlapi.util.mansyntax.ManchesterOWLSyntaxParser org.semanticweb.owlapi.apibinding.OWLManager.createManchesterParser()
private static void org.semanticweb.owlapi.apibinding.OWLManager.lambda$configure$0(org.semanticweb.owlapi.utilities.Injector,org.semanticweb.owlapi.apibinding.OWLManager$InjectorConstants)
public static org.semanticweb.owlapi.model.OWLOntologyManager org.semanticweb.owlapi.apibinding.OWLManager.createOWLOntologyManager()
public static org.semanticweb.owlapi.model.OWLOntologyManager org.semanticweb.owlapi.apibinding.OWLManager.createConcurrentOWLOntologyManager()
For this reason I did not expect a ClassNotFoudException, because the class is present in the jars from the Protege directory ‘bundle’.
Who can tell me what I’m missing?
Thanks in advance!
Pjotr
Pjotr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.