In my case i was using maven build tool and got this error so had to add below dependency from here like below and error resolved.

<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20180130</version>
</dependency>
Answer from Alien on Stack Overflow
🌐
Coderanch
coderanch.com › t › 666886 › java › package-org-json-exist
package org.json does not exist [Solved] (Beginning Java forum at Coderanch)
Here are some details: $ echo $CLASSPATH /usr/share/java $ ll /usr/share/java/json* -rw-r--r-- 1 root root 49176 Jun 12 22:31 /usr/share/java/json-20160212.jar $ jar tf /usr/share/java/json-20160212.jar META-INF/MANIFEST.MF META-INF/ META-INF/maven/ META-INF/maven/org.json/ META-INF/maven/org.json/json/ META-INF/maven/org.json/json/pom.properties META-INF/maven/org.json/json/pom.xml org/ org/json/ org/json/CDL.class org/json/Cookie.class org/json/CookieList.class org/json/HTTP.class org/json/HTTPTokener.class org/json/JSONArray.class org/json/JSONException.class org/json/JSONML.class org/json/
Discussions

error: package org.json does not exist

Currently, org.json.jar sits in the same path

Java expects packages to be in a folder structure.

More on reddit.com
🌐 r/learnjava
3
4
April 28, 2019
java - Getting - package org.json does not exist - unable to use JSONArray / JSONObject - Stack Overflow
I am trying to write a program in Java using Maven in IntelliJ which calls an API using HttpURLConnection and parses the response using JSONArray and JSONObject. I have attempted to import the org.... More on stackoverflow.com
🌐 stackoverflow.com
Is it me, or HackerRank is terrible?

No JSONObject, GSon, or Jackson support in a "read JSON" test? Sounds like a scam.

More on reddit.com
🌐 r/java
28
145
October 22, 2019
Error: org.json does not exist
I'm not used to VSCode but evidently the library is used to compile but not at runtime. Perhaps you have to add it somewhere else, maybe in the run configuration? PS if you want to keep your sanity while developing in java, i strongly suggest to use maven to automate dependencies (unless this is homework then maybe not). More on reddit.com
🌐 r/javahelp
3
5
April 12, 2022
🌐
GitHub
github.com › KrisRaya › hackerank-test › blob › master › src › main › java › hackerank › test › JsonReader.java
hackerank-test/src/main/java/hackerank/test/JsonReader.java at master · KrisRaya/hackerank-test
import org.json.JSONObject; · import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collections; · public class JsonReader { public static void main(String[]args){ String title = "Waterworld"; String url = "https://jsonmock.hackerrank.com/api/movies/search/?Title=" + title; String json = getHTML(url);JSONObject jsonObject = new JSONObject(json); int totalPages = jsonObject.getInt("total_pages"); ArrayList<String> result = getMovieTitles(title, totalPages); System.out.println(result); // System.out.println("\nOutput: \n" + getHTML("https://jsonmock.hackerrank.com/api/movies/search/?Title=Spiderman")); } ·
Author   KrisRaya
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 6135911711634-Package-org-json-simple-x-Does-not-Exist
Package org.json.simple.x Does not Exist – IDEs Support (IntelliJ Platform) | JetBrains
When i Attempt to Build My Project i get 'package org.json.simple does not exist' as an Error, In the Normal View it does not mark any errors, only When Building, Help would be appreciated!
🌐
Reddit
reddit.com › r/learnjava › error: package org.json does not exist
r/learnjava on Reddit: error: package org.json does not exist
April 28, 2019 -

I'm parsing json files using JSONArray and JSONObject but I keep getting the error shown in the title. I've downloaded org.json.jar but I don't know what to do next. Currently, org.json.jar sits in the same path as all of the other java files and classes.

Thanks!

🌐
Reddit
reddit.com › r/java › is it me, or hackerrank is terrible?
r/java on Reddit: Is it me, or HackerRank is terrible?
October 22, 2019 -

Hello there!

So, I was trying to register on 6nomads, and in order to do so, I need to finish test on HackerRank.

HackerRank gives me a simple task like "Create a GET request to X, read json and get specific information from it". Sounds easy enough, right?

Since the UI is terrible, I'm using my own IDE. I write a simple HttpURLConnection mechanism just to get the result. Yup, it's working. I copy it to the HackerRank, nope. Not working. What's wrong? SSL problems. Ok, lets setup SSL to trust all certificates. It's working, phew.

Now to the hard part of the challenge - parse JSON, read data and get specific data. Hoping that the site can work with JSONObject, GSon or Jackson, I started with first. Did everything, ran locally. Perfect. Everything is working as I thought it should be. Time to Copy paste and finish the test... What's this? JSONObject not found? Strange, but OK.

Let's try GSon. Locally it's working as expected. HackerRank gives me a middle finger, saying that it doesn't exist. I don't even try with jackson anymore, I just check if I can use that and nope. Nothing. And now I have 30 minutes left.

After googling, if there're any other ways, I find out about javax.script.ScriptEngineManager which I never used and never heard about. Ok. 30 minutes left, I can do this. And guess what, I did. 5 minutes left, let's do this. "Run tests" and...

javax.script.scriptexception: sun.org.mozilla.javascript.internal.ecmaerror: referenceerror: "Java" is not defined.

I'm furious and I don't know what to do. I find a link in youtube for hackerrank on java, and they were using just javascript code for it, while I was using "Java.asJSONCompatible", because I didn't have much time to get familiar with this ScriptEngineManager. And the end result is - "Come back when you improve your skills". Wow, thank you! Turns out if I don't know how to do something the way YOU want, and expect me to understand it in 30 minutes, I'm bad.

Find elsewhere
🌐
Google Groups
groups.google.com › g › j2objc-discuss › c › O-t4wGix9J8
Parser.java:3: package org.json does not exist
December 10, 2020 - That's correct. The org.json API is not part of the Java Runtime, and so developers shouldn't expect it to be on the bootclasspath.
🌐
Reddit
reddit.com › r/javahelp › error: org.json does not exist
r/javahelp on Reddit: Error: org.json does not exist
April 12, 2022 -

I have been trying to figure out this issue forever now but I can't seem to see what I'm doing wrong. I am using VSCode and added the json library (json-20220329.jar) to my referenced libraries. When I add the jar file the errors in my main file go away regarding JSONObject and JSONArray. Everything looks fine until I try running the code and it says that the "package org.json does not exist." I was wondering if anyone knew what could be the problem.

CODE: (App.java)

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;



import org.json.JSONObject;
import org.json.JSONArray;




public class App {
    public static void main(String[] args) {

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder().uri(URI.create("https://jsonplaceholder.typicode.com/albums")).build();
        client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
            .thenApply(HttpResponse::body)
            .thenAccept(System.out::println)
            .join();
    }

    public static String parse(String responseBody) {
        JSONArray albums = new JSONArray(responseBody);
        for (int i = 0; i < albums.length(); i++)
        {
            JSONObject album = albums.getJSONObject(i);
            int id = album.getInt("id");
            int userID = album.getInt("userId");
            String title = album.getString("title");
            System.out.println(id + "\t" + title + "\t" + userID);
        }
        return null;
    }
    
}

ERROR:

App.java:8: error: package org.json does not exist
import org.json.JSONObject;
               ^
App.java:9: error: package org.json does not exist
import org.json.JSONArray;
               ^
App.java:26: error: cannot find symbol
        JSONArray albums = new JSONArray(responseBody);
        ^
  symbol:   class JSONArray
  location: class App
App.java:26: error: cannot find symbol
        JSONArray albums = new JSONArray(responseBody);
                               ^
  symbol:   class JSONArray
  location: class App
App.java:29: error: cannot find symbol
            JSONObject album = albums.getJSONObject(i);
            ^
  symbol:   class JSONObject
  location: class App
5 errors
Top answer
1 of 2
4
I'm not used to VSCode but evidently the library is used to compile but not at runtime. Perhaps you have to add it somewhere else, maybe in the run configuration? PS if you want to keep your sanity while developing in java, i strongly suggest to use maven to automate dependencies (unless this is homework then maybe not).
2 of 2
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://imgur.com/a/fgoFFis ) 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.
🌐
Reddit
reddit.com › r/codinghelp › error: package org.json does not exist
r/CodingHelp on Reddit: error: package org.json does not exist
April 22, 2022 -

Hi,

I am using java to create a custom nifi processor and i am trying to use the org.json.simple package to access some information from a json. When i try to compile my code i keep getting the error in the title. below is a my pom.xml:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>

 <parent>
     <groupId>1</groupId>
     <artifactId>1</artifactId>
     <version>1</version>
 </parent>

 <artifactId>nifi-processor_stuff-nar</artifactId>
 <version>1</version>
 <packaging>nar</packaging>
 <properties>
     <maven.javadoc.skip>true</maven.javadoc.skip>
     <source.skip>true</source.skip>
 </properties>

 <dependencies>
     <dependency>
         <groupId>1</groupId>
         <artifactId>nifi-processor_stuff-processors</artifactId>
         <version>1</version>
         </dependency>
     <dependency>
         <groupId>com.googlecode.json-simple</groupId>
         <artifactId>json-simple</artifactId>
         <version>1.1.1</version>
     </dependency>
 </dependencies>

</project>
🌐
Ideone
ideone.com › 0gj9y7
0gj9y7 - Online Java Compiler & Debugging Tool - Ideone.com
Main.java:13: error: class JsonSimpleReadExample is public, should be declared in a file named JsonSimpleReadExample.java public class JsonSimpleReadExample { ^ Main.java:3: error: package org.json.simple does not exist import org.json.simple.JSONArray; ^ Main.java:4: error: package org.json.simple does not exist import org.json.simple.JSONObject; ^ Main.java:5: error: package org.json.simple.parser does not exist import org.json.simple.parser.JSONParser; ^ Main.java:6: error: package org.json.simple.parser does not exist import org.json.simple.parser.ParseException; ^ Main.java:17: error: can
🌐
HackerRank
hackerrank.com › contests › quora › challenges › quora-ml-answered › forum › comments › 6444
https://www.hackerrank.com/contests/quora/challeng...
Join over 26 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews.
🌐
GitHub
github.com › SpencerPark › IJava › issues › 106
package does not exist · Issue #106 · SpencerPark/IJava
May 8, 2020 - | import org.json.JSONArray; package org.json does not exist · So how to solve this · No one assigned · No labels · No labels · No projects · No milestone · None yet · No branches or pull requests ·
Author   sant527
🌐
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.
🌐
Reddit
reddit.com › r/learnprogramming › "error: package org.json.simple does not exist" why?
r/learnprogramming on Reddit: "error: package org.json.simple does not exist" Why?
November 1, 2022 -

Trying to use JSON to store some objects locally for retrieval later. Can't figure out why I'm unable to import json. Doesn't work in vim, doesn't work in vsCode, doesn't work in Eclipse.

Read online that I may need to download the json .jar and add to my build path? When googling "json download" its only scammy virus websites.

I'm on a Mac.

Edit: Added pictures

https://imgur.com/a/FlKwMIF

Thanks for the help.

🌐
Stack Overflow
stackoverflow.com › questions › 39546330 › package-org-json-does-not-exist-while-pushig-spring-bootgradle-project-to-hero
java - Package org.json does not exist while pushig spring-boot(gradle) project to heroku - Stack Overflow
November 8, 2017 - I am trying to deploy spring boot gradle project to heroku. The app is running fine locally. But after executing git push heroku master the push crashes with the error error: package org.json does not exist Here is my Procfile
🌐
Coderanch
coderanch.com › t › 694181 › netbeans › ide › Trouble-JSON-imports
Trouble with JSON imports [Solved] (NetBeans forum at Coderanch)
May 15, 2018 - Yes, it is a jar file not a jar.zip. I can see the problem with the image you posted. In the projects window there is a reference to the json-simple.1.1.jar file under libraries. Mine didn't have that so I right-clicked on libraries and added the jar file as a new library.