我正在尝试解析 JSON 中 FourSqure.com 的返回值。我在谷歌上下载了json-simple-1.1.1.jar并将其放在lib文件夹中:"C:\Java\jdk1.7.0\lib",我的Java文件在这个文件夹中:"C:\Java\jdk1.7.0\bin"。
I set classpth: "C:Javajdk1.7.0binGetlocations>set CLASSPATH=$CLASSPATH:$C:Javajdk1.7.0libjson-simple-1.1.1.jar"
并编译它,它显示错误:
C:Javajdk1.7.0binGetlocations>set CLASSPATH=$CLASSPATH:$C:Javajdk1.7.0libjson-simple-1.1.1.jar
C:Javajdk1.7.0binGetlocations>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:Javajdk1.7.0libjson-simple-1.1.1.jar;C:Javajre7libjson-simple-1.1.1.jar;C:Program FilesJavajre7lib;C:Program FilesJavajdk1.7.0lib;"
但是当我跑步时 C:\Java\jdk1.7.0\bin\Getlocations>javac GetLocation.java
它仍然显示此错误:
C:Javajdk1.7.0binGetlocations>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 文件的类路径以使其工作?
回显您的路径以交叉检查您想要的文件位置.jar是否存在。 尝试使用不同版本的 json-simple,以消除兼容性问题。我也有类似的问题。解决问题后回信。快乐编码。