Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-discussion] Creating Protege instances and saving OWL file

Intan Munirah Hamdan niera5 at
Thu Aug 7 08:21:03 PDT 2008

Hi all,

I'm attempting to create instances in Protege (in an already existing owl
file) through Java. The code I have so far appears below:

import java.util.Collection;
import java.util.Iterator;

import edu.stanford.smi.protegex.owl.*;
import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
import edu.stanford.smi.protegex.owl.model.*;

public class IRTStorage
      JenaOWLModel modelModel;
       * @param args
      public void store()
                  String fileName = "N:\\RESEARCH\\Protege\\IRTStorage.owl";
                  FileInputStream fin = new FileInputStream(fileName);
                  modelModel =
                  OWLNamedClass EquipClass =
                  OWLIndividual newInstance =
                  FileOutputStream fout = new FileOutputStream(fileName);

            }catch (Exception err)
                  System.out.println("ERROR: " + err);

      public static void main (String[] args)
            System.out.println("1+1= "+(1+1));
            IRTStorage makeMe = new IRTStorage();


It is able to generate an instance the first time I run the code. However,
when I try to run the code again, I get a "NullPointerException". I then
realized that if after each run of my Java code, I were to open the OWL
file, click save, and then close the OWL file - I would be able to run my
java code again without any error. I suspect that it has something to do
with the way I'm attempting to save the changes to my OWL file (the "save"
function I'm currently using is "deprecated" and perhaps is not saving as it

How should I save this instead?

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the protege-discussion mailing list