JSONObject ClassNotFoundException

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.


Using the latest maven dependency solved the issue for me

<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20171018</version>
</dependency>