RIC ROBERTS

Founder and CTO of Swirrl, creators of PublishMyData.
Manchester-based Ruby, Rails & JavaScript freelancer.
Founding member of OpenDataManchester.

Waiting for Twitter ... (yawn).


@RicRoberts on Twitter

Installing Jena, Joseki and TDB on OS X or Linux

At Swirrl, we’ve been experimenting with different RDF stores so we can evaluate their respective benefits. But when it came to installing Jena, although there is quite a lot of documentation on the website, there was no “getting started” guide for fools like me with rusty Java skillz. Hopefully this blog post will be of some use to someone else in a similar situation.

So I thought I’d document how I got it going on my Mac. Mercifully, the steps are almost identical for Linux – I’ll try to point out any differences where applicable. For reference, I was using Ubuntu Lucid Server but the general idea should apply to other linux flavours.

Note: For those unfamiliar with Jena, Joseki provides an HTTP SPARQL interface to your Jena databases. TDB is a Jena component which provides large scale storage using a non SQL db back-end.

Another note: This article uses a lot of gists, and if you’re viewing this in a feed reader they might not show up. So you might need to read it on the web instead.

Step 1 – Download and unzip

First, download Jena, Joseki and TDB from the sourceforge download area. (I used Jena 2.6.3, Joseki 3.4.2 and TDB 0.8.7).

Unzip the downloads on your Mac (you can then tar them up using the command line, ready to scp up to a linux server, if you like), and put them somewhere sensible on your disk.

Step 2 – Java

Mac OS X Leopard comes with Java 6 installed, but if you are on Ubuntu, you’ll need to install it by running:

sudo apt-get install sun-java6-jre

(You’ll need to add the multiverse repositories to your apt sources.list file first).

Step 3 – Set up your environment

Modify your ~/.profile (Mac) ~/.bashrc (Ubuntu) to include the following lines:

(obviously, change the paths to wherever you moved the downloads to)

Step 4 – Make the scripts executable

At this point, you can test Joseki works, by running:

… and browsing to http://127.0.0.1:2020. You can play with the built-in books dataset at http://127.0.0.1:2020/query.html.

(Kill Joseki with Ctrl-C in the terminal).

Step 5 – Configuring Joseki for your TDB store

Step 5.1 – Add a servlet

In your Joseki directory, edit webapps/joseki/WEB-INF/web.xml and add a new servlet for your service. e.g.

Step 5.2 – Make an html file for your service

Copy the webapps/query.html file and rename it (e.g. myservice.html). Edit the forms to submit to the url you set in the xml file in the previous step. And edit the default SPARQL queries to something sensible.

Step 5.3 – Edit the Joseki config turtle.

Joseki’s config file is in the form of a turtle file, joseki-config.ttl in the root of the Joseki directory. Edit that file and add the following:

Near the top, after all the prefixes:

Add a new service under the others:

Under datasets:

Step 6 – Start Joseki

Step 7 – Load data into your TDB

(change /mydatasetdata to where you set the location 5.3).

Step 8 – Run SPARQL queries

You can now run SPARQL queries against your new dataset through the form on http://127.0.0.1:2020/myservice.html

…or programatically by sending requests to http://localhost:2020/myservice (with the relevant http headers).

Step 9 (optional) – init.d

If you’re doing this on a linux server, the chances are you’ll want Joseki to start automatically. Here’s an simple example init.d file to get you started:

blog comments powered by Disqus