找不到符号HttpClient

时间:2012-07-19 21:02:31

标签: java compiler-errors httpclient

这些事情从来没有对我有意义。我正在尝试使用这个类:

http://www.devdaily.com/java/jwarehouse/commons-httpclient-2.0.1/src/java/org/apache/commons/httpclient/ChunkedInputStream.java.shtml

每次编译时都会遇到一堆错误,例如:

> /ChunkedInputStream.java:85: cannot find symbol
> symbol  : class HttpMethod
> location: class .ChunkedInputStream
>     private HttpMethod method;
>             ^
> /ChunkedInputStream.java:96: cannot find symbol
> symbol  : class HttpMethod
> location: class .ChunkedInputStream
>         final InputStream in, final HttpMethod method) throws IOException {
>                                     ^
> /ChunkedInputStream.java:283: cannot find symbol
> symbol  : variable HttpConstants
> location: class .ChunkedInputStream
>         String dataString = HttpConstants.getString(baos.toByteArray());
>                             ^
> /ChunkedInputStream.java:303: cannot find symbol
> symbol  : class Header
> location: class .ChunkedInputStream
>         Header[] footers = HttpParser.parseHeaders(in);
>         ^
> /ChunkedInputStream.java:303: cannot find symbol
> symbol  : variable HttpParser
> location: class .ChunkedInputStream
>         Header[] footers = HttpParser.parseHeaders(in);

我不应该访问这些对象,因为它是包org.apache.commons.httpclient的一部分; ?我还在我的应用程序中添加了apache http client jars。是什么给了什么?

2 个答案:

答案 0 :(得分:0)

您需要确保导入位于您的程序之上。在项目中使用jar是不够的,除非这些类不在同一个包中,否则你需要在程序中明确地import这些类。

答案 1 :(得分:0)

从内存中,HttpClient具有(至少一个)项目依赖于HttpCore&知道apache,可能更多,像io-commons&登录

我最终链接

  • Apache的mime4j
  • 共享的编解码器
  • 共享记录
  • Httpclient(4)
  • HttpCore(4)
  • HttpMime(4)

但这可能有点矫枉过正,但它对我有用