Tutorial: A starter's starter - owlcs/owlapi GitHub Wiki

I am new to Java and new to OWL API: how do I start?

OWL API is a Java library; what it means is that you do not need to install it like an application; you use it from an application you're writing.

Setting up your system to use the OWL API can be done in two main ways:

  • Use a build system that resolves dependencies for you, such as Maven or Gradle. This is strongly recommended, for two main reasons: one, build systems of this kind are very common, and if you're not familiar with them you will have to become familiar with them soon enough; two, it's much less work to set and update Maven dependencies than it is to update manual dependencies in an IDE or the command line. Look up a Maven tutorial on the details of how Maven works. The OWL API dependency snippets can be found on Maven Central (this link always refers to the latest version).

  • Manually add all the OWL API jars and dependencies to the classpath. This will require you to be familiar with how to add jars to the classpath in your IDE of choice, or to the command line you use to compile your code. OWL API has a large number of jars and an even larger number of jars it depends on, so be aware that you will have a complex job on your hands. For convenience, and at the request of many users, there are zip files containing all the dependencies for a few OWL API versions. You have to unzip these dependency packs and add all the resulting jars to your classpath. See Releases.

Starting to use the OWL API is then a matter of using OWLManager to create OWLOntologyManager instances; each OWLOntologyManager handles a set of OWLOntology objects, which is what ontology files are parsed to.

Your basic snippet will look like this (this example parses the Pizza ontology from a remote URL and prints it out to the console in functional syntax):

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntology(IRI.create("https://protege.stanford.edu/ontologies/pizza/pizza.owl"));
ontology.saveOntology(new FunctionalSyntaxDocumentFormat(), System.out);

At this point, you should take a look at the tutorials:

  • Documentation on this wiki
  • Tutorial by Nico Matentzoglu on OWLAPI 5