I'm trying to use JSON-lib, but I can't get it to run without NoClassDefFoundError
. Here's the code:
import net.sf.json.*;
public class hello {
public static void main(String[] args) {
String settings = "{\"hello\": \"world\"}";
JSONObject obj = (JSONObject)JSONSerializer.toJSON(settings);
System.out.println(obj.toString());
}
}
And the command to compile:
javac -cp lib/json-lib-2.4-jdk15.jar hello.java
And the command to run:
java -cp .:lib/json-lib-2.4-jdk15.jar:lib/commons-lang-2.4.jar hello
I have also tried it with commons-lang3.3, which gives me different errors. I think it might be a version thing.
How do I compile and run a simple example with this library?
If there's a better library without crazy dependencies, I would love to hear about it. I've tried Douglas Crockford's JSON-Java, but I had similar problems.
I would need something with a liberal license, like Apache 2, MIT or similar.