Using Jena with Apache Maven

Apache Maven is a tool to help Java projects manage their dependencies on library code, such as Jena. By declaring a dependency on the core of Jena in your project's pom.xml file, you will get the consistent set of library files that Jena depends on automatically added too.

This page assumes you have Maven installed on your computer. If this is not the case, please read and follow these instructions.

Repositories

Released maven artifacts are mirrored to the central maven repositories. This can take a few days.

The Jena repositories at Apache are:

Stable Jena releases are automatically mirrored by the central Maven repositories, so there will normally be no need to add any extra repositories to your pom.xml or settings.xml.

Specifying Jena or ARQ as a dependency

This is how to specify in your pom.xml file the dependency on a version of Jena and ARQ stable releases:

<dependency>
  <groupId>org.apache.jena</groupId>
  <artifactId>jena-arq</artifactId>
  <version>2.9.0-incubating</version>
</dependency>

You do not need to specify a dependency on Jena, since ARQ depends on Jena and Maven will transitively resolve all the dependencies for you (including Jena). if you do need to use the Apache release repository, add the followng to the <repositories> section of your pom.xml.

<repository>
  <id>apache-repo-releases</id>
  <url>https://repository.apache.org/content/repositories/releases/</url>
  <releases>
   <enabled>true</enabled>
  </releases>
</repository>

Please check for the latest versions.

The artifacts are:

You can run mvn dependency:tree to print the dependency tree. You will see something similar to this (although your versions will be different):

[INFO] +- org.apache.jena:jena-arq:jar:2.9.0-incubating:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.5:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
[INFO] |  \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
[INFO] +- org.apache.jena:jena-core:jar:2.7.0-incubating:compile
[INFO] |  \- org.apache.jena:jena-iri:jar:0.9.0-incubating:compile
[INFO] +- com.ibm.icu:icu4j:jar:3.4.4:compile
[INFO] +- xerces:xercesImpl:jar:2.10.0:compile
[INFO] |  \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- junit:junit:jar:4.9:test
[INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.4:compile
[INFO] \- log4j:log4j:jar:1.2.16:compile

Specifying SDB or TDB as dependencies

For TDB, this is what you should use to point to the latest TDB release:

<dependency>
  <groupId>org.apache.jena</groupId>
  <artifactId>jena-tdb</artifactId>
  <version>0.9.0-incubating</version>
</dependency>

The artifact id for SDB is jena-sdb.

Once again, since SDB and TDB depend on Jena and ARQ this is all you need in your pom.xml file.

(Apache releases of TDB and SDB have not yet been done.)

Specifying dependencies on SNAPSHOTs

If you want to depend on Jena development snapshots, e.g. to get access to recent bug fixes, you should add the following to your pom.xml:

  <repository>
    <id>apache-repo-snapshots</id>
    <url>https://repository.apache.org/content/repositories/snapshots/</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>

For the current Jena SNAPSHOT use:

  <dependency>
    <groupId>org.apache.jena</groupId>
    <artifactId>jena-core</artifactId>
    <version>2.7.1-incubating-SNAPSHOT</version>
  </dependency>

For the current ARQ SNAPSHOT use:

<dependency>
  <groupId>org.apache.jena</groupId>
  <artifactId>jena-arq</artifactId>
  <version>2.9.1-incubating-SNAPSHOT</version>
</dependency>

For the current TDB SNAPSHOT use:

<dependency>
  <groupId>org.apache.jena</groupId>
  <artifactId>jena-tdb</artifactId>
  <version>0.9.0-incubating-SNAPSHOT</version>
</dependency>

Build and install artifacts in your local Maven repository

If you want you can checkout the Jena (or ARQ, or TDB) sources, build the artifacts and install them in your local Maven repository. Simply checkout the sources and type mvn install. This assumes you have Maven and Subversion installed:

svn co https://svn.apache.org/repos/asf/incubator/jena/Jena2/jena/trunk jena-core
cd jena-core
mvn clean install

svn co https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk jena-arq
cd jena-arq
mvn clean install

svn co https://svn.apache.org/repos/asf/incubator/jena/Jena2/TDB/trunk jena-tdb
cd jena-tdb
mvn clean install

Subversion projects also exist for Fuseki and others modules, you can browse the subversion repository here.