How can I import javax.json in eclipse

Tags: , ,



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?

Answer

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'


Source: stackoverflow