错误:包org.json.simple不存在

时间:2012-12-03 19:10:11

标签: json-simple

我试图用JSON解析FourSqure.com的返回值。我在Google上下载json-simple-1.1.1.jar并将其放在lib文件夹中:“C:\ Java \ jdk1.7.0 \ lib”,我的Java文件在此文件夹中:“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" 

并编译它,它显示错误:

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:错误:包org.json.simple不存在 import org.json.simple.JSONArray;                       ^

我尝试以这种方式运行:     “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;"

但是当我跑的时候     C:\ Java \ jdk1.7.0 \ bin \ Getlocations> javac GetLocation.java

它仍然显示此错误:

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;
                  ^

如何设置json-simple-1.1.1.jar文件的Classpath以使其工作?

1 个答案:

答案 0 :(得分:0)

回显您的路径以交叉检查您所需的.jar文件位置是否存在。尝试使用不同版本的json-simple,以消除兼容性问题。我有类似的问题。解决问题后回信。编码愉快。