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
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
Discussions

The curious case of JSON-Java (org.json) and Maven's dependency "hell"
The dependency tree by default exclude duplicates. You can do "mvn dependency:tree -Dverbose=true -DoutputFile=./tree.txt" and look at all inclusions of the specific library. But dependency exclusion is not the best way for your case. It is better to define your desired version within the "" section. You can verify the result by using a verbose output of the dependency:tree goal. More on reddit.com
🌐 r/java
30
25
July 19, 2025
java - org.json dependency with Maven gives NoClassDefFoundError - Stack Overflow
I am using Maven for the first time. I want to use org.json and I have added the dependency to my pom.xml: junit 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
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 › json
Maven Repository: org.json » json
December 24, 2025 - Maven Plugins · Testing · Android Packages · Language Runtime · JVM Languages · Logging Frameworks · JSON Libraries · Java Specifications · Core Utilities · Mocking · Annotation Libraries · Web Assets · HTTP Clients · Logging Bridges · Dependency Injection · XML Processing · Concurrency Libraries · Web Frameworks · Android Platform · Code Generators · View All · Home » org.json » json ·
🌐
Maven Central
central.sonatype.com › artifact › org.json › json
org.json:json - Maven Central
<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20251224</version> </dependency> ... <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.a...
🌐
Reddit
reddit.com › r/java › the curious case of json-java (org.json) and maven's dependency "hell"
r/java on Reddit: The curious case of JSON-Java (org.json) and Maven's dependency "hell"
July 19, 2025 -

Hi. I have a recurring maven(?) issue that I hope is not unique to me and has been solved by someone somewhere.

As JSON parser, I use JSON-Java (the one with package org.json), instead of more famous ones, as the DX and API feel more fit for most/all my projects.

However, from time to time, I reach a very dreadful situation, where the "version" of the JSON-Java library that is available to my code is "not" the one that I have declared in my pom.xml file. In once case, the copyright notice in the source that I could see by clicking the class name in VSCode was from 2010, with the painful difference to the modern version that all parsing methods threw checked exceptions. In another instance, the JSONArray class did not implement Iterable/Iterator where in modern versions it does.

This is likely a maven transitive dependency issue, but the reason it is so visible for this particular library, is because either many libraries already have their own dependency on it, or that it's interface has evolved quite significantly along the way. Likely both.

The solution "in the book" for this is apparently to do "mvn dependency:tree" and exclude JSON-Java explicitly from other dependencies that depend on it. But it doesn't work for me! In my dependency three, only the recent version that is in my own pom file is shown, whereas in code/IDE (VSCode + IntelliJ), I can only use the old version. My deployment involves building a fat Jar, so it happens there too.

Am I doing something wrong? Is there a proven way to make only a certain version of a dependency available to my code, regardless of other versions that may be present deeper in the class path? Does the order of dependencies in pom file matter? and how can I strictly control the versions of dependencies that appear in my fat jar, in case it is possible at all?

Many thanks

🌐
SpigotMC
spigotmc.org › threads › json-import-org-json-isnt-found-maven-dependency.76603
JSON Import (org.json) Isn't Found, Maven Dependency | SpigotMC - High Performance Minecraft Community
July 8, 2015 - Hello! Sorry if this sounds a bit stupid, but I can't figure out how to make my JSON reader work. I have added the org.json dependency in the Maven...
🌐
QA Automation Expert
qaautomation.expert › tag › json-maven-dependency
Json Maven Dependency – QA Automation Expert
June 3, 2021 - The values can be any of these types: Boolean, JSONArray, JSONObject, Number, String, or JSONObject.NULL object. To create a request body using JSON Object, we need to add a Maven dependency.
🌐
Maven Repository
mvnrepository.com › artifact › net.minidev › json-smart
Maven Repository: net.minidev » json-smart
August 2, 2025 - JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These ... ... aar android apache api arm assets build build-system bundle ...
Find elsewhere
🌐
Bukkit
bukkit.org › threads › problem-loading-libraries-with-maven-java-lang-noclassdeffounderror-org-json-jsonobject.428354
Solved - Problem loading libraries with Maven... "java.lang.NoClassDefFoundError: org/json/JSONObject" | Bukkit Forums
August 9, 2016 - Hey everybody. So I'm having a bit of trouble just using an external library, in this case, org.json (though it's the same problem for any maven...
🌐
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
I even tried using json-simple-1.1.1 dependency and json-simple-1.1 dependency and json-20140107 dependency. Error is still the same. So I don't know what is going on. So anyone help me to get the right JSON dependency in pom.xml · Finally I should import these · import org.json.JSONException; import org.json.JSONObject; java · json · maven ·
🌐
Maven Central
central.sonatype.com › artifact › org.json › json › 20230227
org.json:json:20230227 - Maven Central - Sonatype
<dependency> <groupId>org.json...0227</version> <packaging>bundle</packaging> <name>JSON in Java</name> <description> JSON is a light-weight, language independent, data interchange format....
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json › 20210307
Maven Repository: org.json » json » 20210307
March 9, 2021 - 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.
Published   Mar 09, 2021
Version   20210307
🌐
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...
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.

🌐
GitHub
github.com › stleary › JSON-java › blob › master › docs › RELEASES.md
JSON-java/docs/RELEASES.md at master · stleary/JSON-java
Contains the latest code as of 7 Aug 2016 20160212 Java 1.6 compatibility, OSGi bundle. Contains the latest code as of 12 Feb 2016. 20151123 JSONObject and JSONArray initialization with generics. Contains the latest code as of 23 Nov 2015. 20150729 Checkpoint for Maven central repository release.
Author   stleary
🌐
Maven Repository
mvnrepository.com › artifact › org.json › json › 20090211
Maven Repository: org.json » json » 20090211
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 ...
🌐
Maven Central Repository
search.maven.org › org.json › json › 20180813
Maven Central Repository Search
There is a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. The license includes this restriction: "The software shall be used for good, not evil." If your conscience cannot live with that, then choose a different package. ... <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20180813</version> </dependency>
🌐
Maven Central
repo1.maven.org › maven2 › org › json › json › 20210307
Central Repository: 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 json-20210307-javadoc.jar.sha1 2021-03-08 03:55 40 json-20210307-sources.jar 2021-03-08 03:55 79365 json-20210307-sources.jar.asc 2021-03-08 03:55 473 json-20210307-sources.jar.asc.md5 2021-03-08 03:55 32 json-20210307-sources.jar.asc.sha1 2021-03-08 03:55 40 json-20210307-sources.jar.md5 2021-03-08 03:55 32 json-20210307-sources.jar.
🌐
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 ...