user1876508
user1876508

Reputation: 13172

How can I import javax.json in eclipse

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?

Upvotes: 48

Views: 109487

Answers (5)

Rok Povsic
Rok Povsic

Reputation: 4915

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.

Upvotes: 2

user2601995
user2601995

Reputation: 6803

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'

Upvotes: 51

dispake
dispake

Reputation: 3329

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.

Upvotes: 34

Mark R
Mark R

Reputation: 436

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.

Upvotes: 7

Mehul Rathod
Mehul Rathod

Reputation: 1244

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

Upvotes: 0

Related Questions