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 - 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 ·
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
29
25
July 19, 2025
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 - 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
🌐
Maven Central
central.sonatype.com › artifact › org.json › json
org.json:json - Maven Central
<dependency> <groupId>org.json...</version> <packaging>bundle</packaging> <name>JSON in Java</name> <description> JSON is a light-weight, language independent, data interchange format....
🌐
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

🌐
Maven Central Repository
search.maven.org › org.json › json › 20180813
Maven Central Repository Search
<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20180813</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...
🌐
Maven Repository
mvnrepository.com › open-source › json-libraries
Maven Repository: JSON Libraries
JSON parsing, generation, and serialization libraries for working with JSON data.
🌐
Sourcecodeexamples
sourcecodeexamples.net › 2019 › 12 › json-maven-dependency.html
json maven dependency
December 3, 2019 - <!-- https://mvnrepository.com/artifact/org.json/json --> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20190722</version> </dependency> For more details about the proper version to use, check out the following Maven Central link.
Find elsewhere
🌐
SourceForge
json-lib.sourceforge.net
Maven - Json-lib::Welcome
Json-lib requires (at least) the following dependencies in your classpath:
🌐
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
<?xml version="1.0" encoding="UTF-8"?> <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.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ssts</groupId> <artifactId>momcab1</artifactId> <name>momcab1</name> <packaging>war</packaging> <version>1.0.0-BUILD-SNAPSHOT</version> <properties> <java-version>1.7</java-version> <org.springframework-version>4.0.3.RELEASE</org.springframework-version> <org.aspectj-version>1.7.4</org.aspectj-version> <org.sl
🌐
MuleSoft
docs.mulesoft.com › json-module › latest › json-xml-maven
JSON Module XML and Maven Support | MuleSoft Documentation
If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven pom.xml file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the pom.xml file. Paste the following code inside the <mule> tag of the header of your configuration XML: http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd ·
🌐
Maven Repository
mvnrepository.com › artifact › com.fasterxml.jackson.core › jackson-databind
Maven Repository: com.fasterxml.jackson.core » jackson-databind
5 days ago - Jackson Core is a core library for Jackson that provides low-level streaming JSON input/output functionality. ... 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
🌐
QA Automation Expert
qaautomation.expert › tag › json-maven-dependency
Json Maven Dependency – QA Automation Expert
June 3, 2021 - To create a request body using JSON Object, we need to add a Maven dependency.
🌐
JAXB
javaee.github.io › jsonb-spec › getting-started.html
JSON Binding (JSON-B) - Getting started
<repositories> <!-- Needed for JSON-B API --> <repository> <id>java.net-Public</id> <name>Maven Java Net Snapshots and Releases</name> <url>https://maven.java.net/content/groups/public/</url> </repository> </repositories> <dependency> <groupId>javax.json.bind</groupId> <artifactId>javax.json.bind-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>org.eclipse</groupId> <artifactId>yasson</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.json</artifactId> <version>1.1</version> </dependency>
🌐
Maven Central
central.sonatype.com › artifact › org.json › json › 20230227
org.json:json:20230227 - Maven Central - Sonatype
<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20230227</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...
🌐
Apache Maven
maven.apache.org › plugins › maven-dependency-plugin › examples › tree-mojo.html
Dependency Tree Output Formats – Apache Maven Dependency Plugin
February 5, 2026 - mvn dependency:tree -DoutputType=<format> -DoutputFile=<filename> format: One of json, dot, graphml, or tgf.
🌐
Stack Overflow
stackoverflow.com › questions › 72922608 › json-simple-dependency-issue › 72923723
maven - Json Simple dependency Issue - Stack Overflow
Also my project is a javafx ... (JSON exchage). Im at a complete los here on what to do... Thanks for your help. ... So after a lot of trial and error, i have finally fixed it. Instead of vs code I used IntelliJ and added the dependencies there. Its impotant to note, that after every import I had to restart intelliJ also make sure to press the icon as mentioned in this tutorial https://www.jetbrains.com/help/idea/work-with-maven-dependenc...
🌐
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...
🌐
Reddit
reddit.com › r/programming › i need to read json file using java jar maven process if anyone could you please provide me reference projects it will help me a lot
r/programming on Reddit: I need to read json file using Java jar maven process if anyone could you please provide me reference projects it will help me a lot
July 28, 2023 - <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.12.5</version> <!-- Use the latest version available --> </dependency> 3. Place the JSON file: Put the JSON file you want to read in your project's resources directory.