This looks rather similar to ;

http://stackoverflow.com/questions/38351713/creating-individual-in-jena

I suggest local collaboration.

On 13/07/16 16:37, kumar rohit wrote:
Hi
I have the following code in which I want to create an instance/individual
of the class Student. The student name is entered in a text box (in a
button even handler). But it gives exception.

_________________________________________

public class NewJFrame extends javax.swing.JFrame {

     public static void readOntology( String file, OntModel model )
     {

     InputStream in = null;
try
{
in = new FileInputStream( file );
model.read(in, "RDF/XML");
in.close();
} catch (IOException e)
{
e.printStackTrace();
}

My main() is the following.

________________________________

public static void main(String args[]) {



         OntModel model = ModelFactory.createOntologyModel();
                 String file="D://std.owl";
readOntology(file , model );
_______________________________________

Button handler to get student name from text box is:

  private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {




String str=jTextField1.getText();

read(str, null);
}
_____________________________________

WARN [main] (RDFDefaultErrorHandler.java:36) - unknown-source: {W136}
Relative URIs are not permitted in RDF: specifically <RDF/XML>



Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javaapplication4.NewJFrame.read(NewJFrame.java:50)
at javaapplication4.NewJFrame.jButton2ActionPerformed(NewJFrame.java:266)
at javaapplication4.NewJFrame.access$000(NewJFrame.java:27)
at javaapplication4.NewJFrame$1.actionPerformed(NewJFrame.java:103)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)


Reply via email to