First I was generated an ontology inside a method1
. it is successful. Then inside the second method I need to use this generated ontology for another process. I used following code. It gave an error:
Exception in thread "main" java.lang.NullPointerException.
Where is the problem? How I need to take generated ontology in method1
to method2
?
public class OntologyCreation {
public static void main (String args[]) {
//main
OntologyCreation ont = new OntologyCreation();
OntModel m = null;
String ontoClass = null;
ont.method2(ontoClass, m);
public void method1(OntModel m) { //for ontologyCreation
m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
-----
-----
}
public ArrayList<String> method2(String ontoClass, OntModel m) { // 2nd method for use generated ontology to another process
method1(m);
m.read("http://localhost/myont/ont.owl"); ????????
ExtendedIterator<OntClass> classes = ((OntModel) m).listClasses();
----------
----------
}
return xx;
}