Jena includes various command-line utilities which can help you with a variety of tasks in developing Jena-based applications.
An environment variable
JENA_HOME is used by all the command line tools to configure the class path automatically for you. You can set this up as follows:
On Linux / Mac
export JENA_HOME=the directory you downloaded Jena to
SET JENA_HOME =the directory you downloaded Jena to
Once you’ve done the above you should now be able to run the tools from the command line like so:
On Linux / Mac
This command will simply print the versions of Jena and ARQ used in your distribution, all the tools support the
--version option. To find out how to use a specific tool add the
--help flag instead.
Note that many examples of using Jena tools typically use the Linux style invocation because most of the Jena developers work on Linux/Mac platforms. When running on windows simply add
.bat as an extension to the name of the command line tool to run it, on some versions of Windows this may not be required.
If you receive errors stating that a class is not found then it is most likely that
JENA_HOME is not set correctly. As a quick check you can try the following to see if it is set appropriately:
On Linux / Mac
If this command fails then
JENA_HOME is not correctly set, please ensure you have set it correctly and try again.
Windows users may experience problems if trying to run the tools when their
JENA_HOME path contains spaces in it, there are two workarounds for this:
See Reading and Writing RDF in Apache Jena for more information.
riot: parse RDF data, guessing the syntax from the file extension. Assumes that standard input is N-Quads/N-Triples unless
you tell it otherwise with the
riot can also do RDFS inferencing, count triples, convert serializations,
validate syntax, concatenate datasets, and more.
rdfxml: specialized versions of
riot that assume that the input is in the named serialization.
rdfparse: parse an RDF/XML document, for which you can usually just use
riot, but this can also pull triples out of
embedded at arbitrary places in an XML document if you need to deal with those.
See ARQ - Command Line Applications for more about these.
sparql: run a query in a file named as a command line parameter on a dataset in one or more files named as command line parameters.
qparse: parse a query, report on any problems, and output a pretty-printed version of the query.
uparse: do the same thing as
qparse but for update requests.
rsparql: send a local query to a SPARQL endpoint specified with a URL, giving you the same choice of output formats
rupdate: send a local update query to a SPARQL endpoint specified with a URL, assuming that is accepting updates from you.
The following utilities let you work with data stored using a local Fuseki triplestore. They can be useful for automating queries and updates of data stored there. Each requires an assembler file pointing at a dataset as a parameter; Fuseki creates these for you.
For each pair of utilities shown, the first is used with data stored using the TDB format and the second with data stored using the newer and more efficient TDB2 format.
tdb2.tdbquery: query a dataset that has been stored with Fuseki.
tdb2.tdbdump: dump the contents of a Fuseki dataset to standard out.
tdb2.tdbupdate: run an update request against a Fuseki dataset.
tdb2.tdbloader: load a data from a file into a Fuseki dataset.
tdb2.tdbstats: output a short report of information about a Fuseki dataset.
tdb2.tdbbackup: create a gzipped copy of the Fuseki dataset’s triples.
tdb2.tdbcompact: reduce the size of the Fuseki dataset.
rdfdiff: compare the triples in two datasets, regardless of their serializations, and list
which are different between the two datasets. (Modeled on the UNIX
iri: Parse a IRI and tell you about it, with errors and warnings. Good for
checking for issues like proper escaping.