How to write Protege-OWL API?

Protégé Plug-in API is a huge program, consists of well-known packages, such as Jena, Xerces, log4j, Junit, etc. If you have no intention of updating the source code, you can pack the sources into jar files for the convenience in the future.

Installation & Getting Started

  1. Download the sources of Protégé-OWL 3.2.1 and Core Protégé and Protégé-Frames 3.2.1
  2. Unzip the files
  3. Copy the sources of Protégé-OWL and Core Protégé to a directory <Protege_Full_dir>/src.
    • Protégé-OWL will create directories and files under edu/stanford/smi/protegex
    • Core Protégé will create directories and files under edu/stanford/smi/protege
  4. Copy the JAR files to <Protege_Full_dir>/lib. I suggest that copy the Protégé-OWL library first, it includes lots of JAR files. While copy the Core Protégé to /lib will contain a duplicate JAR (junit.jar), ignore it, and copy the other two JAR files (looks.jar and unicode_panel.jar) to the library.
  5. Using Java IDE to create a new project in <Protege_Full_dir>, add all JAR in the /lib to java classpath, and then compile all .java files, where the .class files will be created in /class.
  6. Make jar files. Change directory to /class and type the following commands:
    • jar cvf protegex.jar edu/stanford/smi/protegex/*
    • jar cvf protege.jar edu/stanford/smi/protege/*
  7. Copy the /lib/*.jar, protegex.jar and protege.jar to your working directory <Working_dir>.

A Sample Test Program

In your <Working_dir> you can write a small test program, such as the following:

package test;
import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;
public class OWLAPIDemoApplication {
public static void
main(String[] args) {
    OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
    owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
    OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
    System.out.println("Class URI: " + worldClass.getURI());
  }
}

Execute this program stand-alone. The output should be Class URI: http://hello.com#World.

One thought on “How to write Protege-OWL API?

  1. Hello!
    I need to know the structure of an OWL file. I have to write an OWL file by my own, and I need to know the file structure. I know that first of all I have to write the headers, but what’s next?
    Thanks!

    Like

Leave a comment