Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
In order to use the API in your own applications, you should download the latest binary release and ensure that all of the jar files are in the application classpath.
To do so, we strongly recommend you use a dependency management tool; for example you can use Maven. A Maven dependency (this example is for 5.1.0, most recent release for version 5)
<dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-distribution</artifactId> <version>5.1.0</version> </dependency>
Java version: 8 or newer.
OWL API 5.x requires Java 8. OWLAPI 4.x requires Java 7. OWL API 3.5.x requires Java 6. All are compiled and tested on Oracle JDK 8.
Build your own
If you want to check out the source code and build the binaries yourself using Maven.
Programming with the OWL API
The central point of access is the OWLOntologyManager, which is used to load, create and access ontologies. The examples below show how to create an instance of this class and how to use it.
- The Rough Guide to the OWL API, a tutorial presented at OWLED 2011 (The PDF will be updated to version 4, but it is currently suitable for version 3.4 and 3.5.
- Source code for version 3 for The Rough Guide to the OWL API (includes most of the code available in the subsequent examples).
- Source code for version 4 for The Rough Guide to the OWL API (includes most of the code available in the subsequent examples).
- DL Query Example for 3.x presents an example of how to query an ontology.
- DL Query Example for 4 presents an example of how to query an ontology.
- Examples for 3.x * Examples for 4 include:
- How to load an ontology.
- How to save an ontology.
- How to obtain references to entities (classes, properties, individuals etc.).
- How to work with data types and other data ranges.
- How to work with user defined data ranges (e.g. int > 10).
- How to work with string, data values and language tags.
- How to create an empty ontology, add axioms and save.
- How to specify that an individual is an instance of a class.
- How to specify that two individuals are related to each other.
- How to add an object property assertion (triple) to an ontology.
- How to delete entities (classes, properties and individuals) from an ontology.
- How to create restrictions and ''add them to classes'' as superclasses.
- How to create an ontology and add some rules.
- How to interact with a reasoner.
- How to collect the properties that are used in restrictions on a given class.
- How to work with annotations such as labels and comments.
- How to save *inferred axioms into a new ontology, or back into an existing ontology.
- How two (or more) ontologies can be merged in a simple way.
- How to 'walk' over the asserted structure of an ontology.
- How to use
OWLOntologyIRIMapperto redirect loading and loading of imports.
- How to extract a locality based module from an ontology.
More Code Examples
This example for version 3.x and example for version 4 show how we can calculate and display a basic ontology hierarchy. The example makes use of an OWLReasoner to calculate the class hierarchy, then navigates the structure obtained, printing out basic information for each of the classes. The example uses a StructuralReasoner, which returns information about the hierarchy based solely on the assertions that are made in the ontology.