Json lib 抛出 NestableRuntimeException

来源:互联网 发布:遗传算法的基本步骤 编辑:程序博客网 时间:2024/05/01 08:48

JSONObject 的使用

项目中导入了 json-lib 包,但是在运行如下代码的时候还是出现了如下错误,究其原因是因为缺包,缺了如下5个包:

commons-beanutils-1.8.3

commons-lang-2.6 (注:导入最新的 3.1 版本会继续报如下错误)

commons-collections-3.2.1

commons-logging-1.1.1

ezmorph-1.0.6

Json Lib 下载:json-lib-2.4


import net.sf.json.JSONObject;

public class TestJson {
public static void main(String[] args){
Map<String, String> map = new HashMap<String, String>();
map.put("key", "value");
map.put("name", "abc");
JSONObject json = JSONObject.fromObject(map);
System.out.println(json);
}
}

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException

......

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException

......