【问题标题】:org.apache packages can't be resolved in Eclipseorg.apache 包无法在 Eclipse 中解析
【发布时间】:2012-08-24 13:27:14
【问题描述】:

以下

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

无法解决。我下载了 Apache Http 包并通过外部 jars 选项导入它们,但它仍然无法解决。在 Android 中它似乎可以工作,猜测它在 SDK 中,但在这里我不是在做 Android。我收到了错误的包裹吗?

我相信这是链接:

Apache

【问题讨论】:

  • 有时在导入外部库后,我必须刷新依赖项或关闭并打开项目才能让eclipse错误消失。
  • 好点。正是出于这个原因,我经常做一个 Eclipse“项目,清理”。

标签: java eclipse apache


【解决方案1】:

将罐子拖到我的项目中后,我遇到了同样的问题。

右键单击 jar 并选择 Build-path -> Add-to-Build-Path 为我工作。

【讨论】:

    【解决方案2】:

    听起来好的:

    1) The .jar file in question should be something like "httpcore-4.0.1.jar". 
       Please confirm the name.
    
    2) Adding this to "External Libraries" is absolutely the correct thing to do.
    
    3) For compiling in the Eclipse IDE, you must:
    
       a) Select your project
    
       b) Select "Build Path" > "Add External Libraries"
    
    4) For running in the Eclipse IDE, you must
    
       a) Select "Run" > "Run configurations".  
          Choose your (Java Application?) configuration.
    
       b) Select "Classpath" > "Add External Jar"
    
    5) For running outside of the Eclipse IDE, you must make sure the .jar 
       file is present and your -cp (Classpath) argument is set correctly.
    

    【讨论】:

    【解决方案3】:

    如果您首先将这些 JAR 添加到一个 Android 项目,但现在想在另一个(非 Android)项目中使用它们,请确保您已将这些 JAR 导入到另一个项目中。在 Eclipse 中,每个项目都维护自己的构建类路径设置,因此将 JAR 导入一个项目不会自动使它们可用于其他项目。

    【讨论】:

    • 我不是这个意思。我只是说在 Android 的情况下所有这些包都可用,所以我不必导入它们各自的 jars
    • @E-Riz 如果我想添加一个 jar 以便所有项目都可以使用它该怎么办,我是否必须将它添加到插件文件夹 - C:\eclipse-jee- luna-R-win32\eclipse\plugins ??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-17
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多