OWL API Tutorial
The open-source Java code library for Web Ontology Language (OWL) is an application programming interface (API) used to create classes and methods that specifically load and save OWL files. The API can also be used to manipulate OWL data and perform logic-based analysis. It is primarily used to develop standalone components and applications.
Instructions
-
-
1
Open your preferred Java code editor or a plain text editing application such as Microsoft Notepad or Mac OS X TextEdit. Create a new document where you can practice coding using the OWL API.
-
2
Import the required code packages for OWL to work by adding the following three lines of code to your application, which will automatically download the OWL code libraries:
import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL; -
-
3
Create a new public class for the OWL API demonstration application by using the following code:
public class OWLAPIDemoApplication {
-
4
Add the following application code to create the "Hello World" OWL application that uses the OWL API. This application code uses the getNamespaceManager functions and specifies an owlModel:
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());
}
}
-
1