I was able to successfully download json in my gradle dependencies:

implementation 'org.json:json:20171018'
Answer from David Miller 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 mobile module npm osgi persistence plugin resources rlang sdk server service spring sql starter testing tools ui web webapp
Discussions

android studio cannot resolve import org.json.JSONObject - Stack Overflow
Add the repo in the top most build.gradle, mvnrepository.com/artifact/org.json/json/20141113. More on stackoverflow.com
🌐 stackoverflow.com
Import org.json:json as gradle dependency
Have tried many things in my build.gradle file, among others: compileClasspath( group: ‘org.json’, name: ‘json’, version: ‘20201115’ ) and implementation ‘org.json:json:20201115’ Any ideas please? Still cannot import JSONObject in my beans. Regards, Carlos. More on forum.jmix.io
🌐 forum.jmix.io
0
0
December 27, 2021
Unable to add Json Dependency in build.gradle
Hi. I added this line: compile group: ‘org.json’, name: ‘json’, version: ‘20180813’ in the dependency section of build.gradle but I get an error and I have looked everywhere online. I even talked to Jason on 2073 who was also confused. Error: > Could not resolve all files for ... More on chiefdelphi.com
🌐 chiefdelphi.com
0
0
June 20, 2018
junit - Gradle dependency json-simple error - Stack Overflow
I'm fairly new to Gradle so I'm trying to build a Java project and not sure about the dependencies. I have never gotten Gradle configured to be able to do my tests or now a jar file to compile and... More on stackoverflow.com
🌐 stackoverflow.com
🌐
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 mobile module npm osgi plugin resources rlang sdk server service spring sql starter testing tools ui war web webapp
🌐
Jmix
forum.jmix.io › support
Import org.json:json as gradle dependency - Support - Jmix
December 27, 2021 - Hi, I couldn’t expect this would become as difficult. I am trying to import org.json:json to be used inside my beans. Have tried many things in my build.gradle file, among others: compileClasspath( group: ‘org.json’,…
🌐
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\" }"); ...
Starred by 4.7K users
Forked by 2.6K users
Languages   Java
🌐
Jar-Download
jar-download.com › home › org.json › json › 20180813 › source code › jsonobject.java
org.json.JSONObject Maven / Gradle / Ivy
This is the most * commonly used JSONObject constructor. * * @param source * A string beginning with { (left * brace) and ending with } * (right brace). * @exception JSONException * If there is a syntax error in the source string or a * duplicated key. */ public JSONObject(String source) throws JSONException { this(new JSONTokener(source)); } /** * Construct a JSONObject from a ResourceBundle.
🌐
Chief Delphi
chiefdelphi.com › technical › java
Unable to add Json Dependency in build.gradle - Java - Chief Delphi
June 20, 2018 - Dont add it to build.gradle Download the jar and put it in USER/wpilib/user/java/lib/json.jar it will compile.
Find elsewhere
🌐
Jar-Download
jar-download.com › home › com.github.cliftonlabs › json-simple › 2.1.2 › source code › jsonobject.java
org.json.simple.JSONObject Maven / Gradle / Ivy
org.json.simple.JSONObject maven / gradle build tool code. The class is part of the package ➦ Group: com.github.cliftonlabs ➦ Artifact: json-simple ➦ Version: 2.1.2
🌐
Maven Central
central.sonatype.com › artifact › org.json › json
org.json:json - Maven Central
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. ... <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20251224</version> </dependency>
🌐
Gradle
plugins.gradle.org › search
Gradle - Plugins
Generates JSON schemas from JVM types · Outputs resolved dependencies as JSON grouped by configuration
🌐
GitHub
github.com › spinscale › cookiecutter-elasticsearch-ingest-processor › issues › 7
How to add dependencies? · Issue #7 · spinscale/cookiecutter-elasticsearch-ingest-processor
April 30, 2018 - ... import org.nd4j.*; public class IngestAwesomePlugin extends Plugin implements IngestPlugin { ... When I run gradle build, I get the following error:
Published   Apr 30, 2018
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 32881
Warning about multiple occurrences of `org.json.JSONObject` · Issue #32881 · spring-projects/spring-boot
October 26, 2022 - At quick glance, Jedis usage of org.json:json is limited to org.json.JSONArray and org.json.JSONObject classes (both of which are offered by com.vaadin.external.google:android-json) so one might be tempted to simply exclude org.json:json, but at the same time there's no guarantee that Jedis won't start using something outside of those two in the future.
Author   vpavic
🌐
GitHub
github.com › spring-attic › spring-cloud-deployer-kubernetes › issues › 142
Remove extra occurrences of org.json.JSONObject on the class path · Issue #142 · spring-attic/spring-cloud-deployer-kubernetes
July 14, 2017 - From the build: Found multiple occurrences of org.json.JSONObject on the class path: jar:file:/Users/trisberg/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSO...
Author   trisberg
🌐
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. Apache Maven · Gradle · sbt · ivy · grape · leiningen · buildr · bldCopy to clipboard · <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20180813</version> </dependency> Copy to clipboard ·
🌐
Reddit
reddit.com › r/javahelp › noclassdeffounderror: org/json/jsonobject
r/javahelp on Reddit: NoClassDefFoundError: org/json/JSONObject
September 27, 2017 -

Hi all,

I am working with a JSON object and when I launch my project I get the following error:

java.lang.NoClassDefFoundError: org/json/JSONObject
     viewmodels.LaunchViewModel.buildNextLaunch(LaunchViewModel.java:64)

Looking at line 64...

JSONObject jsonObj = new JSONObject(getHTML("..."));

Looks like I have not setup the dependencies correctly. I am working with IntelliJ with Gradle and I have imported JSON into my external libraries as seen here...

https://i.imgur.com/8VqLFf9.jpg

and here...

https://i.imgur.com/MFupkXg.jpg

My question is does it need to be added to the build.gradle file? Here are my dependencies:

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'junit', name: 'junit', version: '4.12'
}

I think that may be the culprit? But I am still pretty new to this process so any pointers would be sweet.

Thanks!

Edit for mods: The two screenshots are of my external libraries, no code in those. I replaced the remaining screen shot with a code block. Thanks!

Top answer
1 of 2
2
Intellij has its own build system, it can auto sync with gradle but not the other way around, you can't use the library imported from Intellij if you want to use gradle. If you want to use Gradle build, add the dependency into build.gradle: compile group: 'org.json', name: 'json', version: '20180130' But if you want to run it from Intellij, make sure the classpath is configured correctly
2 of 2
1
It seems that you possibly have a screenshot of code in your post NoClassDefFoundError: org/json/JSONObject in r/javahelp . Screenshots of code instead of actual code text is against the Code posting rules of /r/javahelp as is also outlined in the sidebar - Code posting. Never submit screenshots of code instead of code text! If you posted an image merely to illustrate something, kindly ignore this message and do not repost. Your post is still visible to others. I am a bot and cannot distinguish between code screenshots and other images. If you indeed did this wrong, please edit the post so that it uses one of the approved means of posting code. For small bits of code (less than 50 lines in total, single classes only), the default code formatter is fine (one blank line before the code, then 4 spaces before each line of code). Pastebin for programs that consist of a single class only Gist for multi-class programs, or programs that require additional files Github or Bitbucket repositories are also perfectly fine as are other dedicated source code hosting sites. Ideone for executable code snippets that use only the console Please do not reply to this message, because I am a bot. Talk-to-the-bot is the new talk-to-the-hand. If you instead want the classic talk-to-the-hand, just message the moderators. ;) I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
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. Copy below JSON In Java gradle dependency and paste in your project build.gradle file: // https://mvnrepository.com/artifact/org.json/json compile group: 'org.json', name: 'json', version: '20190722' https://repo1.maven.org/maven2/org/json/json/20190722/json-20190722.jar ·
🌐
Android Developers
developer.android.com › api reference › jsonobject
JSONObject | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体