JSON Processing is built, assembled and installed using Maven. It is deployed to the Maven Central repository.

Developers using maven are likely to find it easier to include and manage dependencies of their applications. This document will explain to both maven and non-maven developers how to use JSON Processing in their applications.

In general, if youre not using Maven, youd need to download dependencies (jar files) directly from the Maven repository and include it in the classpath.

Compiling

If you want to compile an application with JSON Processing API, declare a dependency on json-api in maven project. Note that the api dependency doesnt allow you to run the application.

<dependency>
    <groupId>javax.json</groupId>
    <artifactId>javax.json-api</artifactId>
    <version>1.0</version>
</dependency>

For non-maven projects, the JSON Processing API jar can be downloaded and included in the classpath for compiling the applications.

Running

If you want to run an application with JSON Processing API, declare a dependency on json-api implementation in your maven project.

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>1.0.4</version>
</dependency>

For non-maven projects, the JSON Processing RI jar can be downloaded and included in the classpath for running the applications.

Running on Glassfish

GlassFish 4.0 already includes JSON implementation. So for an web application, there is no need to include implementation jar in a war. So declare an json-api dependency with provided scope during the development of the application.

<dependency>
    <groupId>javax.json</groupId>
    <artifactId>javax.json-api</artifactId>
    <scope>provided</scope>
    <version>1.0</version>
</dependency>

Back to top