Add json jar to your classpath

or use java -classpath json.jar ClassName

Or add this to your maven pom.xml depedencies:

<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20090211</version>
</dependency>
Answer from Alya'a Gamal on Stack Overflow
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json
Maven Repository: org.json » json
December 24, 2025 - There are a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven ...
🌐
Maven Central
central.sonatype.com › artifact › org.json › json
org.json:json - Maven Central
</description> <url>https://gi...ng/deploy/maven2/</url> </repository> <snapshotRepository> <id>ossrh</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.jayway.jsonpath</groupId> ...
Discussions

java - JSONObject ClassNotFoundException - Stack Overflow
This is the latest dependency & it don't seems to have "import org.json.JSONObject;". Could you please guide ASAP? More on stackoverflow.com
🌐 stackoverflow.com
java - How to import org.json in maven using dependency - Stack Overflow
I want to use JSON as an interaction between Client and Server. But I am getting an error like this: pom.xml More on stackoverflow.com
🌐 stackoverflow.com
org.json JAR provisioning - Stack Overflow
I was wondering why www.json.org/anyone else doesn't provide an official JAR package of org.json for download? All queries I find of people asking where they can download the JAR results in replies... More on stackoverflow.com
🌐 stackoverflow.com
java - Maven + Spring Boot: Found multiple occurrences of org.json.JSONObject on the class path: - Stack Overflow
When I run mvn test I get this warning. How can I fix it? Found multiple occurrences of org.json.JSONObject on the class path: jar:file:/C:/Users/Chloe/.m2/repository/org/json/json/20140... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Maven Repository
mvnrepository.com › artifact › org.json
Maven Repository: org.json
JSON framework based on org.json implementation (patched for ChargeBee). ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module npm osgi persistence plugin resources rlang sdk server service spring sql starter testing tools ui web webapp
🌐
GitHub
github.com › stleary › JSON-java › blob › master › docs › RELEASES.md
JSON-java/docs/RELEASES.md at master · stleary/JSON-java
JSON-java releases can be found by searching the Maven repository for groupId "org.json" and artifactId "json".
Author   stleary
🌐
Maven Central
repo1.maven.org › maven2 › org › json › json › 20210307
Central Repository: org/json/json/20210307
org/json/json/20210307 · / json-20210307-javadoc.jar 2021-03-08 03:55 175322 json-20210307-javadoc.jar.asc 2021-03-08 03:55 473 json-20210307-javadoc.jar.asc.md5 2021-03-08 03:55 32 json-20210307-javadoc.jar.asc.sha1 2021-03-08 03:55 40 json-20210307-javadoc.jar.md5 2021-03-08 03:55 32 ...
🌐
Maven Central
repo1.maven.org › maven2 › org › json › json › 20230227
Central Repository: org/json/json/20230227
org/json/json/20230227 · / json-20230227-javadoc.jar 2023-02-27 13:38 185665 json-20230227-javadoc.jar.asc 2023-02-27 13:38 659 json-20230227-javadoc.jar.md5 2023-02-27 13:38 32 json-20230227-javadoc.jar.sha1 2023-02-27 13:38 40 json-20230227-sources.jar 2023-02-27 13:38 70293 json-202302...
🌐
Maven Repository
mvnrepository.com › open-source › json-libraries
Maven Repository: JSON Libraries
JSON parsing, generation, and serialization libraries for working with JSON data.
Find elsewhere
🌐
GitHub
github.com › stleary › JSON-java
GitHub - stleary/JSON-java: A reference implementation of a JSON package in Java. · GitHub
The unit tests can be executed from Maven, Gradle, or individually in an IDE e.g. Eclipse. ... import org.json.JSONObject; public class Test { public static void main(String args[]){ JSONObject jo = new JSONObject("{ \"abc\" : \"def\" }"); System.out.println(jo); } }
Starred by 4.7K users
Forked by 2.6K users
Languages   Java
🌐
Maven Central
central.sonatype.com › artifact › org.json › json › 20230227
org.json:json:20230227 - Maven Central - Sonatype
</description> <url>https://github.com/douglascrockford/JSON-java</url> <parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> <version>9</version> </parent> <scm> <url>https://github.com/douglascrockford/JSON-java.git</url> <connection>scm:git:git://github.com/douglascrockford/JSON-java.git</connection> <developerConnection>scm:git:git@github.com:douglascrockford/JSON-java.git</developerConnection> </scm> <licenses> <license> <name>Public Domain</name> <url>https://github.com/stleary/JSON-java/blob/master/LICENSE</url> <distribution>repo</distribution> </license> </l
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json › 20210307
Maven Repository: org.json » json » 20210307
March 9, 2021 - See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. There are a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. ... RepositoriesCentralAcrylicStyleAppodealCarmCloudera ...
Published   Mar 09, 2021
Version   20210307
🌐
Maven Central Repository
search.maven.org › org.json › json › 20180813
Maven Central Repository Search
</description> <url>https://github.com/douglascrockford/JSON-java</url> <parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> <version>9</version> </parent> <scm> <url>https://github.com/douglascrockford/JSON-java.git</url> <connection>scm:git:git://github.com/douglascrockford/JSON-java.git</connection> <developerConnection>scm:git:git@github.com:douglascrockford/JSON-java.git</developerConnection> </scm> <licenses> <license> <name>The JSON License</name> <url>http://json.org/license.html</url> <distribution>repo</distribution> <comments>Copyright (c) 2002 JSON.org P
🌐
Jar-Download
jar-download.com › home › org.json › json › 20180130 › source code › jsonobject.java
org.json.JSONObject Maven / Gradle / Ivy
Search and download functionalities are using the official Maven repository. ... Please wait. This can take some minutes ... ... Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $ You can buy this project and download/modify it how often you want. ... JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java.
🌐
Stack Overflow
stackoverflow.com › questions › 42969716 › how-to-import-org-json-in-maven-using-dependency
java - How to import org.json in maven using dependency - Stack Overflow
import org.json.JSONException; import org.json.JSONObject; java · json · maven · import · org.json · Share · Improve this question · Follow · edited Mar 23, 2017 at 7:43 · Loic P. 71166 silver badges1818 bronze badges · asked Mar 23, 2017 at 7:29 · FIFA oneterahertz · 72022 gold badges1818 silver badges4646 bronze badges 4 · What did you actually do to get this error? Did you try to build the project on the command line? Maybe your local repository is broken - you can try to delete the \repository folder and try again.
Top answer
1 of 6
198

Add under

 <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>

The following exclusion:

 <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>android-json</artifactId>
        </exclusion>
    </exclusions>

Similarly, for Gradle projects:

testCompile("org.springframework.boot:spring-boot-starter-test") {
    exclude group: "com.vaadin.external.google", module:"android-json"
}
2 of 6
47

Background: org.json works great, but has a license clause that some people don't like ("The Software shall be used for Good, not Evil."). So Vaadin wanted to use the library, but couldn't be sure they wouldn't use it for evil someday. Instead, they re-implemented the interface, published android-json and used it as a drop in replacement for org.json. Others began to use android-json as well so that they too would not be bound by the requirement of not using their software for evil.

This is a fine solution, except that when the two libraries are on the classpath, they collide.

Solution: If you get this error from conflicting transitive dependencies, then your best bet is to exclude either Vaadin's android-json library (brought in by Spring), or exclude the org.json library (brought in by another dependency). Vaadin's version is meant to be an identical implementation, but there are subtle differences.

If you're using org.json in your code and it is conflicting with Spring's Vaadin dependency, then I would recommend trying open-json. It's a port of Vaadin's re-implementation of org.json, but they changed the packages so you won't have any conflicts with org.json:json or com.vaadin.external.google:android-json

https://github.com/openjson/openjson

Add gradle dependency:

    implementation('com.github.openjson:openjson:1.0.12')

Or in Maven:

    <dependency>
        <groupId>com.github.openjson</groupId>
        <artifactId>openjson</artifactId>
        <version>1.0.12</version>
    </dependency>

Then update any imports that were being used by org.json classes.

🌐
Maven Repository
mvnrepository.com › artifact › org.json › json › 20160810
Maven Repository: org.json » json » 20160810
August 10, 2016 - There are a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. ... aar amazon android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library maven mobile module npm osgi plugin resources rlang sdk server service spring sql starter testing tools ui war web webapp
🌐
Reddit
reddit.com › r/javahelp › can't import "json-20240303" library into my project.
r/javahelp on Reddit: Can't import "json-20240303" library into my project.
June 17, 2024 -

I'm going to start by saying I'm a complete novice in Java. I've started computer science recently and I've got a project where I have to create a project to represent a server using sockets. The server will has to function as a control a library's book record/register. My professor provided a .json file with the book lists which I have to use.

I tried creating the project on VS Code, but after following these steps:

Downloaded the library from the Maven Repository.

Created a lib folder in your project's root directory and move the json-20230303.jar file to this folder.

My code couldn't import the library and this error appeared every time I tried to use the library:

"src\Gerenciador.java:2: error: package org.json does not exist import org.json.JSONArray;"

After a while I thought it would be easier to import the library on the Ide Eclipse, but after creating the project and adding it via the Build Path option, it still didn't work. Even though the library appeared in the Libraries section in the Java Build Path.

This error: "The type org.json.JSONObject is not accessible" keeps appearing.

I don't know how to fix the problem. I think I'm calling on the library wrong, but I don't know how I should do it. If there is any information missing, let me know and I'll provide it, it's my first time asking for help on a programming forum.

Top answer
1 of 3
2
Show your pom.xml
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json › 20180130
Maven Repository: org.json » json » 20180130
There are a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. ... aar amazon android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library maven mobile module npm osgi plugin resources rlang sdk server service spring sql starter testing tools ui war web webapp
🌐
Maven Central
repo1.maven.org › maven2 › org › json › json › 20180813 › json-20180813.pom
https://repo1.maven.org/maven2/org/json/json/20180813/ ...
JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL.