Apache Httpclient 简明教程

Apache HttpClient - Environment Setup

在本教程中,我们将说明如何在 Eclipse IDE 中为 HttpClient 设置环境。在继续安装之前,确保你的系统中已经安装了 Eclipse。如果没有,下载并安装 Eclipse。

有关 Eclipse 的更多信息,请参阅我们的 Eclipse Tutorial

Step 1 - Download the dependency JAR file

打开 HttpClient(组件)网站的官方 homepage 并转到下载页面

httpcomponents downloads

然后,下载最新稳定版本的 HttpClient 。在整个教程中,我们使用版本 4.5.6,因此下载文件 4.5.6.zip

在下载的文件夹中,你会找到一个名为 lib 的文件夹,其中包含要在项目的类路径中添加的必需 Jar 文件,以使用 HttpClient。

Step 2 - Create a project and set build path

打开 eclipse 并创建一个示例项目。右键单击项目,选择选项 Build Path → Configure Build Path ,如下所示。

build path

Libraries 选项卡的 Java Build Path 框架中,单击 Add External JARs

add external jars

然后选择 lib 文件夹中的所有 jar 文件,然后单击 Apply and Close

jar files

在 eclipse 中,您已做好所有准备使用 HttpClient 库。