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

java - org.json not found in jar with Maven - Stack Overflow
I've been attempting to export my new Java code from Eclipse into a JAR and have been having issues with the JSON Libraries. At first, I exported using my current JDK, which would compile for Java ... More on stackoverflow.com
🌐 stackoverflow.com
maven - java.lang.ClassNotFoundException: org.json.JSONException - Stack Overflow
I am building a simple maven project. I used build path to add json as a third party library and also added it to web-inf library. In the end, i added the dependency in pom.xml. However, with all the More on stackoverflow.com
🌐 stackoverflow.com
December 26, 2014
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 - org.json.simple.JSONObject VS org.json.JSONObject , JSONException cannot be resolved to a type - Stack Overflow
Second: I have a code with org.json.JSONObject and org.json.JSONException. When I edit the code in eclipse ( JUNO) it resolves the type of JSONException and imports the package org.json.JSONException but when I run the project using maven in command line I have a problem ( JSONException cannot ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
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 ·
🌐
Jar-Download
jar-download.com › home › com.jwebmp › json › 0.63.0.54 › source code › jsonexception.java
org.json.JSONException Maven / Gradle / Ivy
org.json.JSONException maven / gradle build tool code. The class is part of the package ➦ Group: com.jwebmp ➦ Artifact: json ➦ Version: 0.63.0.54
🌐
Stack Overflow
stackoverflow.com › questions › 66676905 › org-json-not-found-in-jar-with-maven
java - org.json not found in jar with Maven - Stack Overflow
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException at aoClient.AoApi.<init>(AoApi.java:10) at aoClient.Main.main(Main.java:224) Caused by: java.lang.ClassNotFoundException: org.json.JSONException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) I tried to use a different version of JSON in the Maven POM file, without success, and I have tried linking the JAR file of the JSON library to my build path, and even checking the order and export tab of the build path with no change.
🌐
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...
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.

Find elsewhere
🌐
Jar-Download
jar-download.com › home › org.json › json › 20180130 › source code › jsonobject.java
org.json.JSONObject Maven / Gradle / Ivy
But if multiple values are accumulated, * then the result will be like append. * * @param key * A key string. * @param value * An object to be accumulated under the key. * @return this. * @throws JSONException * If the value is an invalid number or if the key is null.
🌐
GitHub
github.com › stleary › JSON-java › blob › master › docs › RELEASES.md
JSON-java/docs/RELEASES.md at master · stleary/JSON-java
20230227 Fix for CVE-2022-45688 and recent commits 20220924 New License - public domain, and some minor updates 20220320 Wrap StackOverflow with JSONException 20211205 Recent commits and some bug fixes for similar() 20210307 Recent commits and potentially breaking fix to JSONPointer 20201115 Recent commits and first release after project structure change 20200518 Recent commits and snapshot before project structure change 20190722 Recent commits 20180813 POM change to include Automatic-Module-Name (#431) JSONObject(Map) now throws an exception if any of a map keys are null (#405) 20180130 Recent commits 20171018 Checkpoint for recent commits.
Author   stleary
🌐
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

🌐
TutorialsPoint
tutorialspoint.com › org_json › org_json_quick_guide.htm
Org.Json - Quick Guide
String xmlText = "<Other ... Misshaped close tag at 34 [character 35 line 1] JSONException is a Runtime Exception and is not required to be declared as throws statement....
🌐
Stack Overflow
stackoverflow.com › questions › 75021192 › org-json-is-not-accessible-in-java-maven-project-as-a-dependency
org.json.* is not accessible in JAVA Maven Project as a dependency - Stack Overflow
Remove <type>bundle</type> and try again. See What is the meaning of type "bundle" in a maven dependency? for more info. ... I did that and there were no errors on pom but I still could not reference it in my code. I get this error: The type org.json.JSONArray is not accessible
🌐
Jar-Download
jar-download.com › home › org.codehaus.jettison › jettison › 1.3.6 › source code › jsonexception.java
org.codehaus.jettison.json.JSONException Maven / Gradle / Ivy
org.codehaus.jettison.json.JSONException maven / gradle build tool code. The class is part of the package ➦ Group: org.codehaus.jettison ➦ Artifact: jettison ➦ Version: 1.3.6
🌐
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 ...
🌐
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 ...