欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JSON需要导入的jar包

程序员文章站 2022-05-28 20:42:22
...

要使用JSON除了要导入众所周知的json-lib-2.1.jar、json-lib-2.2.3-jdk15.jar两个包,还有导入其他一堆包,哪怕弄一个简单的JSONObject demoJson = JSONObject.fromObject(message);也得导入,要时缺了其中一个,必然报错。

 

异常1:org.apache.commons.lang.exception.NestableRuntimeException

java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 14 more

需要导入commons-lang-2.3.jar

 

异常2:net.sf.ezmorph.Morpher

Caused by: java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 2 more

需要导入ezmorph-1.0.6.jar

 

异常3:org.apache.commons.logging.LogFactory

Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 3 more

 需要导入commons-logging-1.0.4.jar

 

异常4:org.apache.commons.collections.map.MultiKeyMap

Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.MultiKeyMap
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 4 more

需要导入:commons-collections-3.2.jar

 

异常5:org.apache.commons.beanutils.DynaBean

Caused by: java.lang.ClassNotFoundException: org.apache.commons.beanutils.DynaBean
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 4 more

需要导入:commons-beanutils-1.7.0.jar

 

综上,想用一个最简单的JSON也得导入以下的七个包:

json-lib-2.1.jar
json-lib-2.2.3-jdk15.jar
commons-lang-2.3.jar
ezmorph-1.0.6.jar
commons-logging-1.0.4.jar
commons-collections-3.2.jar
commons-beanutils-1.7.0.jar

 

伤不起啊!

 

相关标签: json jar包