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

implementation 'org.json:json:20171018'
Answer from David Miller on Stack Overflow
🌐
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’, name: ‘json’, version: ‘20201115’ ) and implementation ...
Discussions

android studio cannot resolve import org.json.JSONObject - Stack Overflow
I used libgdx to build my project and I am having issues using the JSONObject class. When I add import org.json.JSONObject, it says it cannot resolve. How do I add that library to my project? Her... More on stackoverflow.com
🌐 stackoverflow.com
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
can't import json to gradle
Just use implementation "org.json:json:20171018" You don't need the "G:\document" part. You also don't need to download any jars, gradle does it automatically. Make sure you add the maven central repository as shown here: https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:maven_central More on reddit.com
🌐 r/gradle
2
3
June 27, 2021
java - Gradle Jar Dependency Error - Stack Overflow
I have a java program that I use Gradle to build. In this program I use the JSON jar "org.json:json:2014113" this program compiles and works just fine when I run it in my IDE (IntelliJ 14) It also More on stackoverflow.com
🌐 stackoverflow.com
🌐
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. I would not recommend following this advice - adding to build.gradle allows you to more easily update dependencies when needed and automatically download them when first setting up a project on a new computer.
🌐
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 ...
🌐
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 ...
🌐
Sourcecodeexamples
sourcecodeexamples.net › 2019 › 12 › json-simple-maven-dependency.html
json-simple maven dependency
December 3, 2019 - Copy below JSON.simple Gradle dependency and paste in your project build.gradle file: // https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1' https://repo1.maven.org/maven2/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar ·
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
🌐
Maltzj
maltzj.com › posts › dependency-management-gradle
Adventures in Gradle Dependency Resolution – Jonathan Maltz
After scratching our head for a while, someone on our team had the idea to look at the pom.xml for json-simple (Gradle uses Maven's pom.xml format for resolving dependencies, even though it is a separate build system) and discovered that JUnit is declared as a dependency of json-simple.
🌐
Jar-Download
jar-download.com › home › org.json › json › 20180813 › source code › jsonobject.java
org.json.JSONObject Maven / Gradle / Ivy
org.json.JSONObject maven / gradle build tool code. The class is part of the package ➦ Group: org.json ➦ Artifact: json ➦ Version: 20180813
🌐
GitHub
github.com › spinscale › cookiecutter-elasticsearch-ingest-processor › issues › 7
How to add dependencies? · Issue #7 · spinscale/cookiecutter-elasticsearch-ingest-processor
April 30, 2018 - // In this section you declare the dependencies for your production and test code // Note, the two dependencies are not really needed as the buildscript dependency gets them in already // they are just here as an example dependencies { compile 'org.elasticsearch:elasticsearch:6.2.4' compile 'org.nd4j:nd4j-native-platform:0.9.1' testCompile 'org.elasticsearch.test:framework:6.2.4' } And then I try to import nd4j in IngestAwesomePlugin.java: ... import org.nd4j.*; public class IngestAwesomePlugin extends Plugin implements IngestPlugin { ... When I run gradle build, I get the following error:
Published   Apr 30, 2018
🌐
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.
🌐
Kotlinlang
slack-chats.kotlinlang.org › t › 8095474 › why-is-it-impossible-to-use-json-in-gradle-from-8-0-onwards-
Why Is it impossible to use json in Gradle from 8 0 onwards kotlinlang #gradle
org.json.simple.*, so this isn’t particular to Gradle 8. My guess is that you used to have a Gradle plugin that had a dependency on org.json, but you haven’t applied the plugin, or the plugin has been updated to remove that dependency.
🌐
Maven Central
central.sonatype.com › artifact › org.json › json
org.json:json - Maven Central
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.
🌐
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:
🌐
Maven Repository
mvnrepository.com › artifact › com.googlecode.json-simple › json-simple › 1.1
Maven Repository: com.googlecode.json-simple » json-simple » 1.1
Dependency Injection · XML Processing · Web Frameworks · Android Platform · Concurrency Libraries · Defect Detection Metadata · Code Generators · Top Categories · Home » com.googlecode.json-simple » json-simple » 1.1 · A simple Java toolkit for JSON · Note: There is a new version for this artifact · Maven · Gradle ·
🌐
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>