In Eclipse , navigate to
Windows ->Preferences -> Java -> Build Path -> ClassPath Variables
If your classpath variable 'JSON_JARS' is not present there, add it there, alongwith its location.
This should resolve your 'unbound classpath variable' error, if you have this error.
Moreover, put your execution codes in some method, or at least in main.
For example :
package test;
import org.json.simple.*;
public class JSONTest {
public void testMethod(){
JSONObject obj = new JSONObject();
obj.put("name","test");
JSONArray list = new JSONArray();
list.add("1234");
}
public static void main(String [] args){
JSONObject obj = new JSONObject();
obj.put("name","test");
JSONArray list = new JSONArray();
list.add("1234");
}
}
This doesn't throw any error.
For the code which you have attached, if I am correct, there is no way for the code to populate the object and list, to get executed. This is why you get those errors.