我对 Java 是个新手,而且一直是个很喜欢的人。话虽这么说,我正在尝试使用 JSON 库(包?类?Java 术语真是令人困惑!),并且在将它们添加为参考时遇到问题。
这三个导入无法解析:
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
我去了 json.org 并 下载 Java 库,但我不知道如何处理它们。我尝试进入项目属性并添加外部类但无济于事。我注意到下载的文件夹充满了 .java 文件。我该怎么处理这些?
很抱歉在这里提出这样一个菜鸟问题,但我很困惑。
I'm brand new to Java and have always been a c kind-of-guy. That being said, I'm trying to use the JSON libraries (packages? classes? Java terminology is so damn confusing!) and am having issues adding them as a reference.
These three imports cannot be resolved:
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
I went to json.org and downloaded the Java libraries but I'm not sure what to do with them. I've tried to go into project properties and add an external class to no avail. I noticed the downloaded folder is full of .java files. What am I supposed to do with these?
Sorry to present such a noob question on here, but I'm stumped.
发布评论
评论(4)
我相信这是一个错误的下载。您需要这里的 JSON-Simple 库 http://code.google.com/p/json-简单/。您的链接指向另一个实现。
下载后,*.jar 应添加到类路径中。如何做到这一点取决于您使用的工具。在 Eclipse 中,右键单击项目,Properties->Libraries 并添加新的 JAR。
This is a wrong download I believe. You need JSON-Simple library from here http://code.google.com/p/json-simple/ . Your link points to another implementation.
After download the *.jar should be added to the classpath. How you do it depends on the tools you use. In Eclipse it is right-click on the project, Properties->Libraries and add the new JAR.
嘿,只需从这个网站下载 json.jar
http://www.java2s.com /Code/Jar/j/Downloadjsonsimple11jar.htm
之后
找到 json jar 并添加它们。
并将这些包添加到您的 java 文件中:)
Hey just download the json.jar from this website
http://www.java2s.com/Code/Jar/j/Downloadjsonsimple11jar.htm
after that
find the json jar(s) and add them.
and add these package in your java file :)
请注意:Json 和 JsonSimple 不同。如果您使用 Maven,您可以通过将此依赖项添加到 pom 文件来获取 json-simple:
http://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1
Be advised: Json and JsonSimple are not the same. If you are using Maven you can get json-simple by adding this dependency to your pom file:
http://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1