Skip to content

Apache Jena Installation & Configuration

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.

Prerequisites:

  • Maven Installed: Make sure Maven is installed on your computer. If not, please follow Maven installation instructions.
  • IDE Installed: Install an IDE of your choice. This guide assumes you are using Eclipse.

Steps for Using Apache Jena with Maven in Eclipse:

  1. Open Eclipse:
    Launch Eclipse and select your workspace directory.

  2. Install Maven Integration for Eclipse:
    If not already installed:

    • Go to Help > Eclipse Marketplace...
    • Search for “Maven Integration for Eclipse” or “m2e”.
    • Install it if it’s not already installed.
  3. Create a New Maven Project:

    • Go to File > New > Project...
    • Select Maven > Maven Project and click Next.
    • Choose a workspace location or use the default and click Next.
  4. Select an Archetype:

    • Select maven-archetype-quickstart (or another archetype if you prefer) and click Next.
    • Enter your Group ID (e.g., com.example), Artifact ID (e.g., jena-example), and Version (e.g., 1.0-SNAPSHOT).
    • Click Finish.
  5. Add Apache Jena Dependencies:

    • Right-click on the newly created project in the Project Explorer.
    • Select Properties > Java Build Path > Libraries > Add Maven Dependency....
    • This will open the pom.xml file.
    • Add the Apache Jena dependencies inside the <dependencies> section of pom.xml.

Here’s how to specify a dependency on a version of Jena:

<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>X.Y.Z</version>
</dependency>
  1. Create Your Java Class:

    • In the src/main/java directory, create a new Java class (e.g., JenaExample.java).
    • Add your Java code using Apache Jena.
  2. Run Your Project:

    • Right-click on your project and select Run As > Java Application.