47

I have installed eclipse ide for EE developers and I am receiving an import error for

import javax.json.Json;
import javax.json.JsonReader;
etc.

I have right clicked on project folder -> clicked properties -> clicked Java build path -> add library -> JRE System Library,

but the dependencies that show up are already imported. How can I import the javax.json package?

1
  • 1
    Are you using Java 7 with Eclipse?
    – dispake
    Aug 20, 2013 at 23:38

5 Answers 5

50

If using Maven, add this dependency to your pom.xml

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

For Gradle, add this to your build.gradle

compile 'javax.json:javax.json-api:1.0'
4
34

Going to assume that you are not using Java 7 and thus need to add the JAR file directly to your project path:

Here's the link to the JAR

And where it came from: http://jsonp.java.net/

Download and add to your project build path.

2
  • 3
    java 7 includes this package?
    – Thufir
    Feb 22, 2016 at 19:08
  • 4
    Note that javax.json is included in Java EE 7, not Java SE 7.
    – ziesemer
    Jun 5, 2017 at 19:46
7

You need to get a hold of the Jar from https://java.net/projects/jsonp/

Then got to project folder -> clicked properties -> clicked Java build path -> Add External Jars...

From here you can import the downloaded Jar (library) into your project.

1

Using javax.json group (what is in the accepted version) doesn't work for me. I get this:

javax.json.JsonException: Provider org.glassfish.json.JsonProviderImpl not found

Instead, what does work for me is the following (put this in the dependencies section of build.gradle if you're using Gradle):

implementation "org.glassfish:javax.json:1.1.4"

To find the latest version of the library, see the library's search.maven.org page.

0

You will have to download the Jar from https://java.net/projects/jsonp/ as they are not yet part of main Java runtime, download the jar and add it to your classpath and it should work

JSR http://jcp.org/en/jsr/detail?id=353

1
  • It gets a zip not a jar, so would be good to explain how to make a jar from a zip.
    – Elisabeth
    Nov 29, 2017 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.