Reputation: 13172
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
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
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
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
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
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