Apache Jena

Apache Jena is a framework for working with RDF. It can create, manipulate, query, etc. RDF both in memory and via a triplestore.

The standard distribution of Jena has many useful programs for working with RDF. See this page for more info.

Fuseki triplestore

In IN5800 we will use the Jena Fueski Triplestore database. This is a server-based database management system for triples. A Makefile that sets up a Fuseki-server on your local machine can be found here. Read the Makefile to see the commands involved in making a server, starting it, loading data into it, querying it, and cleaning it.

To download Apache Jena Fuseki, a default config file, and make the necessary folder structure, simply execute:

make init

To then start the server, execute:

make start-server

To load data into the triplestore execute:

make load-data

To query the database, execute:

make query-data

Finally, to clean the database (i.e. delete all triples) execute:

make clean-db

To change the name of the database you need to edit two files:

  1. Edit the serverName-variable in the Makefile;
  2. Edit fuseki/fuseki.ttl and change "test" in the line with fuseki:name "test" ;.

To change which file is loaded by the load-data-command, change the dataFile-variable in the Makefile. To change the query-file used by query-data, change the queryFile-variable in the Makefile.

Jena also has a Web-based UI for interacting with the database. Simply open the following link in your favorite browser:

[[http://localhost:3030/]]

There you can see the names of the servers currently running, as well as a query-button you can press to get to a page where you can execute SPARQL-queries over the database.

Jenarulereasoner

In IN5800 we will also use Jena’s Rule Reasoner, however there is no CLI-program to interact directly with this reasoner (one can only use it via Jena’s API). However, a simple CLI-wrapper around this API can be downloaded here.

See java -jar jenarulereasoner.jar --help for info on how to use it. Below is an example use of the program, that applies the Jena-rules in the file ex.rules to the RDF-files ex1.ttl and ex2.ttl, and executes the query contained in q.sparql:

java -jar jenarulereasoner.jar -m query -r ex.rules -q q.sparql ex1.ttl ex2.ttl

The below command simply executes the rules in ex.rules to the same files as above (ex1.ttl and ex2.ttl), but outputs all triples (both explicit and inferred), and writes the result to out.ttl:

java -jar jenarulereasoner.jar -m expand -r ex.rules -o out.ttl ex1.ttl ex2.ttl 

Tutorials and guides