如何使用org.apache.commons包? [英] How to use org.apache.commons package?

查看:270
本文介绍了如何使用org.apache.commons包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在各种网络的例子我看到进口,如:

On various web examples I see imports such as:

import org.apache.commons.net.ftp.FTPClient;

我不明白如何使用这些,和Apache的网站是相当不清楚。如何我使用这些类?我期待我需要下载的东西,但有点方向将是极大的AP preciated。

I don't understand how to use these, and the apache website is fairly unclear. How to I use these classes? I'm expecting I need to download something, but a little direction would be greatly appreciated.

推荐答案

您应该下载包含这些库的jar文件。图书馆可以将它们添加到类路径中。

You are supposed to download the jar files that contain these libraries. Libraries may be used by adding them to the classpath.

有关共享网络,你需要从共享网下载页面下载二进制文件。然后你要提取的文件和公共净2-2.jar文件添加到某个位置,你可以从你的应用程序例如访问到/ lib中。

For Commons Net you need to download the binary files from Commons Net download page. Then you have to extract the file and add the commons-net-2-2.jar file to some location where you can access it from your application e.g. to /lib.

如果你正在运行在命令行应用程序,你必须定义java命令类路径: java命令; LIB /公共净2-2.jar的myapp <​​/ code>。了解如何设置可以从Oracle文档中发现的类路径。您必须指定你需要在不包括Java运行时提供了隐含在classpath所有目录和jar文件。请注意,有'。在类路径,它是用来包括当前目录中的情况下,你编译的类位于当前目录中。

If you're running your application from the command-line you'll have to define the classpath in the java command: java -cp .;lib/commons-net-2-2.jar myapp. More info about how to set the classpath can be found from Oracle documentation. You must specify all directories and jar files you'll need in the classpath excluding those implicitely provided by the Java runtime. Notice that there is '.' in the classpath, it is used to include the current directory in case your compiled class is located in the current directory.

有关更高级的阅读,您可能希望了解如何定义你的classpath自己的JAR文件,或战争的目录结构文件当你创建一个Web应用程序。

For more advanced reading, you might want to read about how to define the classpath for your own jar files, or the directory structure of a war file when you're creating a web application.

如果您使用的是IDE,比如Eclipse,你要记住的库添加到您的构建路径之前,IDE会识别它,并允许您使用的库。

If you are using an IDE, such as Eclipse, you have to remember to add the library to your build path before the IDE will recognize it and allow you to use the library.

这篇关于如何使用org.apache.commons包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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