I am new to Protege API and I have just created on Eclipse a small application which uses an external OWL file. Also I did import all the necessary libraries.
import java.util.Collection;
import java.util.Iterator;
import edu.stanford.smi.protege.exception.OntologyLoadException;
import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.model.*;
public class Trial {
public static void main(String[] args) throws OntologyLoadException {
String uri = "C:/Documents and Settings/Anto/Desktop/travel.owl";
OWLModel owlModel = ProtegeOWL.createJenaOWLModelFromURI(uri);
Collection classes = owlModel.getUserDefinedOWLNamedClasses();
for (Iterator it = classes.iterator(); it.hasNext();) {
OWLNamedClass cls = (OWLNamedClass) it.next();
Collection instances = cls.getInstances(false);
System.out.println("Class " + cls.getBrowserText() + " ("
+ instances.size() + ")");
for (Iterator jt = instances.iterator(); jt.hasNext();) {
OWLIndividual individual = (OWLIndividual) jt.next();
System.out.println(" - " + individual.getBrowserText());
}
}
}
}
When I do compile however I get the following errors:
WARNING: [Local Folder Repository] The specified file must be a directory.
(C:Documents and SettingsAntoMy DocumentsEclipse
WorkspaceProtegeTrialpluginsedu.stanford.smi.protegex.owl)
LocalFolderRepository.update()
SEVERE: Exception caught -- java.net.URISyntaxException: Illegal character in path at
index 12: C:/Documents and Settings/CiuffreA/Desktop/travel.owl
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at java.net.URI$Parser.parseHierarchical(URI.java:3066)
at java.net.URI$Parser.parse(URI.java:3014)
at java.net.URI.<init>(URI.java:578)
at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.getFileURI(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(Unknown Source)
at edu.stanford.smi.protege.model.Project.loadDomainKB(Unknown Source)
at edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(Unknown Source)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(Unknown Source)
at Trial.main(Trial.java:14)
Exception in thread "main" java.lang.NullPointerException
at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(Unknown Source)
at edu.stanford.smi.protege.model.Project.loadDomainKB(Unknown Source)
at edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(Unknown Source)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(Unknown Source)
at Trial.main(Trial.java:14)
Does anyone have an idea on where the problem should be?