Code examples for my book "Practical Semantic Web Programming (Java, Scala, Clojure, and JRuby Edition)
Java Scala Ruby


Companion software examples for the book “Practical Semantic Web and Linked Data Applications (Java, Scala, Clojure, and JRuby Edition)”

You can get the free PDF of this book on my Open Content web page

You can order a print book (or a paid for PDF) from Lulu:

All of the book software examples that I wrote are licensed using the LGPL license version 3.

I use a variety of 3rd party JAR files contained in the lib directory.

While most of the software is written in Java, I have made an attempt to also support people who prefer JRuby, Clojure, or Scala with wrappers for those languages.

Examples work with AllegroGraph 4.0 and Sesame

I have written compatibility wrappers so the book examples can use either the open source Sesame RDF repository or the commercial AllegroGraph product. My wrapper for Sesame adds support for geolocation and text indexing and search.

As of June 2010 you can download the free edition of AllegroGraph version 4 at

Using IntelliJ

Using the free community version of IntelliJ 10, make sure the Clojure and Scala plugins are installed (should be by default), set default JDK version to 5.0, create a new project “Create Java project using existing sources” and make sure do include all of the JAR files in the lib sub directory into the project's required resources (do this by “Open Module Settings”, click the “Dependencies” tab, Add -> “Single Entry Module Library…”, select all JAR files in lib and the Sesame sub directory of lib, hit “Apply”. Then make sure the test directory is in your source path.).

You should then be able to run any of the examples by right mouse clicking any file in the test directory and choosing the “Run…” option.

Using Eclipse

The directions are similar to those for IntelliJ: create a new Java Eclipse project, import the example directory from this git repository, make sure that all JAR files in the lib directory are imported as external JAR files, and then run the Java test programs in the test directory. Note: I am not an Eclipse user: if anyone will donate directions for installing and running the Eclipse Clojure and Scala plugins, I will add those directions here.

11/11/2013 note: I changed the behavior of the DBPediaLookup class, giving better results

11/11/2013 note: the Clojure code is in the ZIP file UnZI this file first if you want to use the CLojure examples.

7/13/2010 note: current AG 4.04 release breaks geospatial queries: a new 4.1 release in August will fix this.

-Mark Watson

3/12/2011 Thanks to Alex Ott for Clojure code improvements and edits for my book.