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

java - Gradle build - not able to import org.json - Stack Overflow
How would that be done for org.json? 2022-10-30T12:05:44.38Z+00:00 ... Make sure your dependency configuration is set correct in your build.gradle, especially important when running plugins like a test framework. For example, I wanted to use JsonObject in a Gatling test. More on stackoverflow.com
🌐 stackoverflow.com
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
Import org.json:json as gradle dependency
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 ... 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
🌐
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 ...
🌐
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.
🌐
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 ...
🌐
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
🌐
HatchJS
hatchjs.com › home › the import org.json cannot be resolved in eclipse: a guide to fixing the error
The Import org.json Cannot Be Resolved in Eclipse: A Guide to Fixing the Error
January 5, 2024 - A: There are a few possible reasons why you might get this error in a Gradle project. ... In this blog post, we discussed the common error “the import org.json cannot be resolved” in Eclipse. We identified the two main causes of this error and provided solutions for each.
🌐
DigitalOcean
digitalocean.com › community › tutorials › json-simple-example
json-simple example | DigitalOcean
August 4, 2022 - JSONObject extends HashMap but doesn’t support Generics, so Eclipse IDE gives warning as below. Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap<K,V> should be parameterized · For reading JSON from file, we have to use org.json.simple.parser.JSONParser class.
🌐
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>
🌐
Jar-Download
jar-download.com › home › org.json
Download org.json JAR files with all dependencies
Download org.json JAR files ✓ With dependencies ✓ Documentation ✓ Source code
🌐
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.
🌐
Reddit
reddit.com › r/javahelp › can't import "json-20240303" library into my project.
r/javahelp on Reddit: Can't import "json-20240303" library into my project.
June 17, 2024 -

I'm going to start by saying I'm a complete novice in Java. I've started computer science recently and I've got a project where I have to create a project to represent a server using sockets. The server will has to function as a control a library's book record/register. My professor provided a .json file with the book lists which I have to use.

I tried creating the project on VS Code, but after following these steps:

Downloaded the library from the Maven Repository.

Created a lib folder in your project's root directory and move the json-20230303.jar file to this folder.

My code couldn't import the library and this error appeared every time I tried to use the library:

"src\Gerenciador.java:2: error: package org.json does not exist import org.json.JSONArray;"

After a while I thought it would be easier to import the library on the Ide Eclipse, but after creating the project and adding it via the Build Path option, it still didn't work. Even though the library appeared in the Libraries section in the Java Build Path.

This error: "The type org.json.JSONObject is not accessible" keeps appearing.

I don't know how to fix the problem. I think I'm calling on the library wrong, but I don't know how I should do it. If there is any information missing, let me know and I'll provide it, it's my first time asking for help on a programming forum.

Top answer
1 of 3
2
Show your pom.xml
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
TutorialsPoint
tutorialspoint.com › org_json › org_json_quick_guide.htm
Org.Json - Quick Guide
JSONObject class is a unordered collection of key-value pairs. It provides methods to access values by key and to put values. Following types are supported − ... package com.tutorialspoint; import org.json.JSONObject; public class JsonDemo ...
🌐
Jar-download
jar-download.com › maven-repository-class-search.php
Download dependencies for java class org.json.JSONArray
Artifact json Group one.xingyi Version 1.0 Organization not specified URL Not specified License not specified Dependencies amount 3 Dependencies json, rest, rest, There are maybe transitive dependencies! 44 downloads · Maven · Gradle · Ivy · SBT · Group: org.eclipse.scout.rt Artifact: org.eclipse.scout.json Show documentation Show source ·
🌐
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