JSONObject ClassNotFoundException

后端 未结 3 938
没有蜡笔的小新
没有蜡笔的小新 2020-12-31 11:21

I am working in IntelliJ and using Maven. I have a class that uses JSONObject:

import org.json.JSONObject;

try {
  JSONObject documentObj = new          


        
相关标签:
3条回答
  • 2020-12-31 12:06

    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.

    0 讨论(0)
  • 2020-12-31 12:10

    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>
    
    0 讨论(0)
  • 2020-12-31 12:19

    Using the latest maven dependency solved the issue for me

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20171018</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题