Java JSON 包导入失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24714493/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java JSON package importing failure
提问by kernelbug
I'm working with OpenJDK 7 (openjdk-7-jdk) under Ubuntu, compiling my code with following command
我正在 Ubuntu 下使用 OpenJDK 7 (openjdk-7-jdk),使用以下命令编译我的代码
javac -d ./classes ./src/Program.java
My code contains imports
我的代码包含导入
...
import java.util.concurrent.ExecutorService;
import javax.json.Json;
import javax.json.stream.JsonParser;
import javax.swing.text.html.parser.ParserDelegator;
...
and i'm getting the following error
我收到以下错误
./src/Program.java:21: error: package javax.json does not exist
import javax.json.Json;
^
./src/Program.java:22: error: package javax.json.stream does not exist
import javax.json.stream.JsonParser;
^
It is curious that there is no problems with importing from javax.swing or java.util.
奇怪的是,从 javax.swing 或 java.util 导入都没有问题。
Please tell, what am i doing wrong?
请告诉,我做错了什么?
采纳答案by kernelbug
steps to follow:
要遵循的步骤:
Download javax.json jar file.
As you have downloaded this jar file, specify it in java compiler classpath, using javac
-classpath
key.As you have your code compiled, then use
-cp
key forjava
command to specify this jar file in the runtime classpath upon your code execution.
下载此 jar 文件后,请使用 javac
-classpath
键在 java 编译器类路径中指定它。编译代码后,请在代码执行时使用
-cp
key forjava
命令在运行时类路径中指定此 jar 文件。
More detailed information on classpath settings can be found here: http://kevinboone.net/classpath.html
可以在此处找到有关类路径设置的更多详细信息:http: //kevinboone.net/classpath.html