rdf2java is a small tool written in Java. It allows easy handling of RDF data. Instead of using an RDF api for creating and searching for RDF triples, i.e., (subject, predicate, object), you just work with Java objects representing RDF subjects / objects.

So, in a nutshell, instead of

 Property authorProperty = ...
 Resource myBook = ...
 myResource.addProperty(authorProperty, "Kobayashi");

you write

 Book myBook = ...

which not only is more readable but also a lot more comfortable (think of auto-completion in modern programming environments!).

Typically, you first create an RDFS (RDF Schema) file, containing declarations for classes and properties. RDF data (e.g. in an RDF file) refers to this RDFS file, just like an XML file can refer to a DTD or to an XML Schema file. The RDF Schema specifies what kind of RDF subjects (i.e. instances of these classes) are allowed and how they are linked to each other (-> properties). So, you have RDFS specifications and RDF data (instances) matching this RDF Schema.

Implementation Details

First, create the .java files containing the code implementing the RDFS instance Java wrapper classes. Each of these wrapper classes is a subclass of JenaResourceWrapper which extends a Jena Resource in turn. You have to use for that.

An ObjectTracker instance keeps a map of RDFS class URIs and the corresponding Java classes. The ObjectTracker is the place to ask for wrapper objects. The ObjectTracker takes an URI and returns the most specialized subclass of JenaResourceWrapper that fits to the RDF:type of the URI supplied. Then, you can use that object's methods to manipulate the underlying RDF. No caching is done - the wrapper object's methods directly work on the Jena RDF model.

You have to register all wrapper classes with the ObjectTracker before using it. This is what the Constants file generated by rdfs2class is for.

That's it :-).

In case you wonder, if you use a wrapper object's getter method that returns not a literal but an instance, the corresponding wrapper object will get created automatically if not already existing. This is why every wrapper object is linked to an ObjectTracker - only the ObjectTracker can create new wrapper objects.


  • missing support for anonymous resources, RDF sequences, RDFS meta classes, RDFS multiple inheritance


The new Jena-based version of rdf2java is rather new and more or less in prototype stadium. We use it for our projects and with little manual work it processes even quite large RDFS ontologies though.


If you have questions feel free to contact me via email (Sven.Schwarz However, the code is not maintained anymore.

rdf2java is just one of the available RDF-to-Java mapper/wrapper frameworks. Please have a look at for more information and more alternative solutions!


The classes that generate wrapper files are subject to the General Public License. Runtime components are subject to the modified BSD license. See file headers for details.


The original tool was written by Michael Sintek. Sven Schwarz developed his tool further to suit our increasing needs in the FRODO project. Malte Kiesel extended rdf2java to suit the needs of the SmartWeb project.

Additional Stuff

In addition to really needed stuff like, e.g., the KnowledgeBase class, other useful tools emerged naturally.

  • RDFDiff - compare two RDF files and listing new/missing triples
  • RDFNice - order RDF triples in case a hierarchy can be found
  • RDFDump - dump RDF as triples
  • Here is an easy to understand tutorial: OldRDF2JavaUsingDFKIKnowledgeBase - unfortunately it's an old tutorial - some parts may work a bit different, but the basic idea and procedure is still the same.
Last modified 8 years ago Last modified on 02/10/10 18:34:58