一、报错问题
Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.test.test.TTTT.main(TTTT.java:9)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 13 more
二、代码分析
package com.test.test;
import java.util.Iterator;
import net.sf.json.JSONObject;
public class TTTT {
public static void main(String[] args) {
JSONObject bandwidth = new JSONObject();
JSONObject data = new JSONObject();
data.put("in", "88");
data.put("out", "99");
bandwidth.put("vnic00375", data);
bandwidth.put("vnic00376", data);
bandwidth.put("vnic00377", data);
Iterator it = bandwidth.keys();
JSONObject bandwidth2 = new JSONObject();
int i=1;
while(it.hasNext()) {
String key = (String) it.next();
String value = bandwidth.getString(key);
key="内网网卡"+i;
bandwidth2.put(key, value);
i++;
}
System.out.println(bandwidth2);
}
}
三、解决方案
四、运行结果