error: package org.json.simple does not exist

jimmy picture jimmy · Dec 3, 2012 · Viewed 8.2k times · Source

I am trying to parse the return values from FourSqure.com in JSON. I dowload the json-simple-1.1.1.jar on Google and put it in the lib folder: "C:\Java\jdk1.7.0\lib" and my Java file is in this folder: "C:\Java\jdk1.7.0\bin" .

I set classpth: "C:\Java\jdk1.7.0\bin\Getlocations>set CLASSPATH=$CLASSPATH:$C:\Java\jdk1.7.0\lib\json-simple-1.1.1.jar" 

and compile it , it show error:

C:\Java\jdk1.7.0\bin\Getlocations>set CLASSPATH=$CLASSPATH:$C:\Java\jdk1.7.0\lib\json-simple-1.1.1.jar

C:\Java\jdk1.7.0\bin\Getlocations>javac GetLocation.java

GetLocation.java:22: error: package org.json.simple does not exist import org.json.simple.JSONArray; ^

and I try to run this way: "C:\Java\jdk1.7.0\bin\Getlocations>javac -classpath .;$C:\Java\jdk1.7.0\lib\json-simple-1.1.1.jar GetLocation.java"

it still doesn't recognize "package org.json.simple".


After this I also try to set classpath in the "Invironment Variables" in the Window : 
"C:\Java\jdk1.7.0\lib\json-simple-1.1.1.jar;C:\Java\jre7\lib\json-simple-1.1.1.jar;C:\Program Files\Java\jre7\lib;C:\Program Files\Java\jdk1.7.0\lib;"

but when I run C:\Java\jdk1.7.0\bin\Getlocations>javac GetLocation.java

it still shows this error:

C:\Java\jdk1.7.0\bin\Getlocations>javac GetLocation.java
GetLocation.java:22: error: package org.json.simple does not exist
import org.json.simple.JSONArray;
                  ^

How can I set the Classpath for the json-simple-1.1.1.jar file to make it work ?

Answer

Aadil Hoda picture Aadil Hoda · Jun 18, 2019

echo your path to crosscheck if your desired location of .jar file is there or not. Try with different versions of json-simple, to eliminate the compatibility issue. I had the similar issue. Write back after solving the issue. Happy coding.