You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by emy ashry <em...@yahoo.com> on 2011/09/22 21:43:09 UTC

use owl ontology in java application

i have tried to use jena in netbeans to read owl file from ontology 3.4.6, but there is many errors spicially in read() method.
the code is:
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null );
               m.getDocumentManager().addAltEntry( http://www.w3.org/2001/sw/WebOnt/guide-src/carads,
                                            "file:carads.owl");
  m.read( "file:carads.owl" );
the errors are:
Exception in thread "main" java.io.FileNotFoundException: carads.owl (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
        at java.net.URL.openStream(URL.java:1010)
        at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:209)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2130)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2100)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2061)
        at testing55.Main.main(Main.java:34)
com.hp.hpl.jena.shared.WrappedIOException: rethrew: java.io.FileNotFoundException: carads.owl (The system cannot find the file specified)
        at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:213)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2130)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2100)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2061)
        at testing55.Main.main(Main.java:34)
Caused by: java.io.FileNotFoundException: carads.owl (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
        at java.net.URL.openStream(URL.java:1010)
        at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:209)
        ... 4 more
Java Result: 1
please ,i need help quickly. because i hve tried many methods to load the file bu i cannot do it.
thanks. 

Re: use owl ontology in java application

Posted by Dave Reynolds <da...@gmail.com>.
On Thu, 2011-09-22 at 12:43 -0700, emy ashry wrote: 
> i have tried to use jena in netbeans to read owl file from ontology 3.4.6, but there is many errors spicially in read() method.
> the code is:
> OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null );
>                m.getDocumentManager().addAltEntry( http://www.w3.org/2001/sw/WebOnt/guide-src/carads,
>                                             "file:carads.owl");
>   m.read( "file:carads.owl" );
> the errors are:
> Exception in thread "main" java.io.FileNotFoundException: carads.owl (The system cannot find the file specified)

That means what it says, the file "carads.owl" can't be found. 

Perhaps you have a mistake in the file name, or the file is in a
different directory from where you are running java.

Dave