在Eclipse中无法导入的Apache HTTP [英] Can't import Apache HTTP in Eclipse

查看:396
本文介绍了在Eclipse中无法导入的Apache HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用例如code来自Apache文档,如下所示:

I'm using example code from the Apache documentation, shown here:

        final WebClient webClient = new WebClient();

    // Get the first page
    final HtmlPage page1 = webClient.getPage("http://some_url");

    // Get the form that we are dealing with and within that form, 
    // find the submit button and the field that we want to change.
    final HtmlForm form = page1.getFormByName("myform");

    final HtmlSubmitInput button = form.getInputByName("submitbutton");
    final HtmlTextInput textField = form.getInputByName("userid");

    // Change the value of the text field
    textField.setValueAttribute("root");

    // Now submit the form by clicking the button and get back the second page.
    final HtmlPage page2 = button.click();

    webClient.closeAllWindows();

我从Web客户端,HtmlPage,...的HtmlForm基本上,应该从Apache的进口一切错误,只是没有。

I get errors from WebClient, HtmlPage, HtmlForm... basically, everything that should be imported from Apache, just isn't.

我跟着一群在网络上指南指导我的藿外部罐添加到我的构建路径,而据我可以告诉大家,一切都设置正确。我试过清洁工程,重新启动Eclipse中,关闭/打开项目等似乎没有任何工作。

I've followed a bunch of guides on the web directing me on hwo to add external jars to my build path, and as far as I can tell, everything is set-up correctly. I've tried Cleaning the project, restarting Eclipse, closing/opening the project, etc. Nothing seems to work.

有关参考,我下载的.jar文件从这个网站: http://hc.apache.org/

For reference, I downloaded the .JARs from this website: http://hc.apache.org/.

我的import语句:

My import statements:

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;

我的错误消息:

[2014年6月23日12时43分55秒 - CampusHappenings]霉素1错误;中止
[2014年6月23日12点43分55秒 - CampusHappenings]转换为Dalvik的格式失败,出现错误1

[2014-06-23 12:43:55 - CampusHappenings] Dx 1 error; aborting [2014-06-23 12:43:55 - CampusHappenings] Conversion to Dalvik format failed with error 1

堆栈跟踪的整体实在是太长了复制,但它的东西做的JAR文件的HtmlUnit本身,而不是与我的code。他们都看起来像这样:

The entirety of the stacktrace is much too long to copy, but it's something to do with the htmlunit JARs themselves, not with my code. They all look something like this:

霉素警告:忽略InnerClasses属性为匿名内部类
(org.apache.xalan.lib.sql.SecuritySupport12 $ 4)不拿出一个
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。

Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.xalan.lib.sql.SecuritySupport12$4) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format.

的思考?我很困惑。

推荐答案

由于我见过的Dalvik在错误日志中,我假设你写你的code为Android,但尝试使用通用Apache的HttpClient的版本,可能无法与Android兼容。你真的应该检查这个Apache的文件,并尝试他们4.3端口专门针对Android的。

Since I've seen Dalvik in the error log, I'm assuming that you're writing your code for Android but try to use a common version of Apache's HttpClient that might not be compatible with Android. You should really check this Apache's document and try their 4.3 port specifically aimed for Android.

https://hc.apache.org/httpcomponents-客户端版本4.3.x / Android的port.html

HttpClient的为Android罐子可以在这里找到:<一href=\"http://search.maven.org/remotecontent?filepath=org/apache/httpcomponents/httpclient-android/4.3.3/httpclient-android-4.3.3.jar\" rel=\"nofollow\">http://search.maven.org/remotecontent?filepath=org/apache/httpcomponents/httpclient-android/4.3.3/httpclient-android-4.3.3.jar

HttpClient for Android jar can be found here: http://search.maven.org/remotecontent?filepath=org/apache/httpcomponents/httpclient-android/4.3.3/httpclient-android-4.3.3.jar

这篇关于在Eclipse中无法导入的Apache HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆