List in Java converted to JSON error (i)

Source: Internet
Author: User

1. Error description

Exception in thread "main" java.lang.noclassdeffounderror:org/apache/commons/lang/exception/ Nestableruntimeexceptionat Java.lang.ClassLoader.defineClass1 (Native Method) at Java.lang.ClassLoader.defineClass ( classloader.java:800) at Java.security.SecureClassLoader.defineClass (secureclassloader.java:142) at Java.net.URLClassLoader.defineClass (urlclassloader.java:449) at java.net.urlclassloader.access$100 ( urlclassloader.java:71) at Java.net.urlclassloader$1.run (urlclassloader.java:361) at Java.net.urlclassloader$1.run (urlclassloader.java:355) at java.security.AccessController.doPrivileged (Native Method) at Java.net.URLClassLoader.findClass (urlclassloader.java:354) at Java.lang.ClassLoader.loadClass (Classloader.java : 425) at Sun.misc.launcher$appclassloader.loadclass (launcher.java:308) at Java.lang.ClassLoader.loadClass ( classloader.java:358) at Com.you.model.ListToJSON.main (listtojson.java:29) caused by: Java.lang.ClassNotFoundException:org.apache.commons.lang.exception.NestableRuntimeExceptionat java.Net. Urlclassloader$1.run (urlclassloader.java:366) at Java.net.urlclassloader$1.run (urlclassloader.java:355) at Java.security.AccessController.doPrivileged (Native Method) at Java.net.URLClassLoader.findClass ( urlclassloader.java:354) at Java.lang.ClassLoader.loadClass (classloader.java:425) at sun.misc.launcher$ Appclassloader.loadclass (launcher.java:308) at Java.lang.ClassLoader.loadClass (classloader.java:358) ... More

2. Cause of error

/** * Convert List to JSON */package com.you.model;import java.util.arraylist;import Java.util.list;import net.sf.json.jsonarray;/** * @author Youhaidong * */public class Listtojson {/** * @param args */public static void main (St Ring[] args) {list<string> List = new arraylist<string> () List.add ("Spring"); List.add ("Summer"); List.add ("Autumn"); List.add ("Winter"); Jsonarray Jsonarray = jsonarray.fromobject (list); System.out.println ("list converted to JSON:" + jsonarray.tostring ());}}

Missing jar Package


3. Solutions

Copy "Commons-lang-2.4.jar" to Lib

List in Java converted to JSON error (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.