Probably your simple json.jar file isn't in your classpath.
Answer from Arun Manivannan on Stack Overflowjava - org.json.simple cannot be resolved - Stack Overflow
java - How to import org.json in maven using dependency - Stack Overflow
org.json JAR provisioning - Stack Overflow
java - Looking for JsonParser dependency - Stack Overflow
Probably your simple json.jar file isn't in your classpath.
I was facing same issue in my Spring Integration project. I added below JSON dependencies in pom.xml file. It works for me.
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
A list of versions can be found here: https://mvnrepository.com/artifact/org.json/json
Have you considered using Maven? for instance, if you wanted a JAR to pars JSON you could just include...
http://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl/1.9.6
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.6</version>
</dependency>
in a pom.xml, this will give you the jar for JSON.
Or better yet, use the org.json one...
http://mvnrepository.com/artifact/org.json/json
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
I downloaded a jar from here: http://code.google.com/p/org-json-java/downloads/detail?name=org.json-20120521.jar&can=2&q=
If you are using Json-simple, use the below maven dependency.
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
Link: https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1
If you are using maven, you can add the following dependency
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
you can also download the artefact manually here
http://central.maven.org/maven2/javax/javaee-api/7.0/javaee-api-7.0.jar
For Gradle, use
compile group: 'javax', name: 'javaee-api', version: '7.0'
The site https://mvnrepository.com shows you the different dependencies for different build systems.
Please note that this is only one possible dependency. You can certainly find smaller dependencies, which only contain the classes you want. Simply search for it on google or mavencentral.
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>
As of today (15th July 2020), you need to use latest maven repository as per below:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
</dependency>
For any new version in the future, you can check it here:
- https://mvnrepository.com/artifact/org.json/json
Then simply replace 20200518 with latest new version value.
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