【发布时间】:2010-01-15 23:37:48
【问题描述】:
我正在使用 Mozilla Rhino 编写一个 JavaScript 服务器应用程序。我想在我的项目中包含 HttpClient 类以轻松访问网络,但我不知道如何配置我的 Eclipse 项目以让 Rhino 加载 HttpClient JAR 文件。
我已将 js.jar(来自 Rhino)和 httpclient-4.0.1.jar 添加到我在 Eclipse 中的项目构建路径中,并且在我的运行配置中,我从 Rhino 的 js.jar(它找到)中指定了 Main 类,并在我的JavaScript 文件我基本上是这样做的:
importPackage(org.apache.http.client.methods);
var get = new HttpGet("<some url returning json data>");
get.execute();
print(get.getResponseBodyAsString());
这样说失败了:
Exception in thread "Thread-0" org.mozilla.javascript.EcmaError: ReferenceError: "HttpGet" is not defined.
怎么会这么难?我一定是做错了什么。
【问题讨论】:
标签: java javascript eclipse classpath rhino