Search code examples
javauriprotegeowl-api

Protege OWL API loading ontologies with URI


I'm working with the Protege OWL API in a java program and am having a problem loading my ontologies. When I try a URI, it works. However, when I try to use a local path on my computer, it doesn't work.

 package Test;

 import edu.stanford.smi.protegex.owl.ProtegeOWL;
 import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;

 public class  TestLoad {
    public static JenaOWLModel Model =null;
    public static String URI="http://protege.cim3.net/file/pub/ontologies/travel/travel.owl";          
    // change the URI by this "C:/Users/Sara/Desktop/travel.owl"; 

    public static void main(String[] args) 
    {
        try
        {
            Model=ProtegeOWL.createJenaOWLModelFromURI(URI);
            System.out.println("Success");
        }
        catch (Exception exception)
        {   
            System.out.println("Error");
        }
     }
 }

Solution

  • The string you're using is not a complete URI because C: is not a protocol. Prefix the string with file:///and you should get better results.