"constructor JSONParser in class JSONParser cannot be applied to given types" error occured
java, json, netbeans
Solution
Check your import statements. You will be importing it from jdk.nashorn. The code you are trying to attempt is from org.json.simple.parser.JSONParser
Problem
I am trying to build a weather app in Java language and Netbeans(As IDE). The code is as follows: ``` URL link = new URL("http://api.dataweave.in/v1/weather/findByCity/?api_key=a93abfaea2a98410be0df095f72df25d7a5d5eb5&city=Shimla&date=20130501"); URLConnection uc1 = link.openConnection(); BufferedReader in1 = new BufferedReader(new InputStreamReader(uc1.getInputStream())); StringBuilder weather = new StringBuilder(); weather.append(in1.readLine() + "\n"); String line="0"; while ((line = in1.readLine()) != null) { weather.append(line + "\n"); } String result=weather.toString(); JSONParser parser=new JSONParser(); JSONObject obj = (JSONObject)parser.parse(result); JSONArray jarr = (JSONArray) obj.get("data"); System.out.println(((JSONObject) jarr.get(0)).get("city")); System.out.println(((JSONObject) jarr.get(0)).get("country")); System.out.println(((JSONObject) jarr.get(0)).get("min_today")); System.out.println(((JSONObject) jarr.get(0)).get("max_today")); System.out.println(((JSONObject) jarr.get(0)).get("desc_today")); System.out.println(((JSONObject) jarr.get(0)).get("date")); ``` On the Line ``` JSONParser parser=new JSONParser(); JSONObject obj = (JSONObject)parser.parse(result); ``` I am getting this error: ``` constructor JSONParser in class JSONParser cannot be applied to given types required: Source, Error Manager found: No arguments reason: actual and formal arguments list differs in length ``` I already have "json-simple" jar file as a library. Now what should I do?