在eclipse中使用java库
我对 eclipse 有点陌生,想要使用以下库,以便我可以使用它们实现的对象(HttpClient 和 Java csv)。我如何导入这些库以便我可以用它们编写一些java?
I'm a bit new to eclipse and want to use the following libraries so that I can use their implemented objects (HttpClient and Java csv). How do I import these libraries so that I can write some java with them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要做的是将库添加到项目的构建路径(编译时将使用的类路径)。在 Eclipse 中,您可以通过右键单击项目并选择
Properties
(或者在Project 中选择项目时按
、[Alt]+[Enter]
)来执行此操作ExplorerNavigator
或Package Explorer
视图),然后从侧边栏和Libraries
中选择Java Build Path
> 选项卡,您可以在其中添加 JAR。请注意,
添加 JAR
和外部 JAR
之间的区别在于,外部 JAR
将在项目中添加外部依赖项,因为 JAR 的绝对路径位于您的文件系统将被放入您的项目配置中。通过添加 JAR
,您可以从工作区中选择 JAR。我发现创建一个
lib
文件夹(与我的src
文件夹处于同一级别)并将所有 JAR 放入其中,然后将它们添加到使用Add JARs
选项构建路径。这使得项目可移植,因为只有相对路径引用项目内的资源,而不是来自其他工作区项目的绝对路径或资源。What you're looking to do is add the libraries to your project's build path (the class path that will be used while compiling). In Eclipse, you can do this by right-clicking your project and choosing
Properties
(or hitting[Alt]+[Enter]
when the project is selected inProject Explorer
,Navigator
orPackage Explorer
views) and thenJava Build Path
from the sidebar and theLibraries
tab where you can add JARs.Note the difference between
Add JARs
andExternal JARs
is thatExternal JARs
will add an external dependency in your project since the absolute path to the JAR on your filesystem will be put into your project's configuration. WithAdd JARs
you can select JARs from within your workspace.I find it to be a good practice to create a
lib
folder (at the same level as mysrc
folder) and put all my JARs in there and then add them to the build path with theAdd JARs
option. This makes the project portable since there are only relative paths referring to resources within the project rather than absolute paths or resources from other workspace projects.您可以在项目构建路径中添加要使用的 .jar 文件。您可以通过右键单击您的项目来访问此窗口。选择“构建路径”-> “配置构建路径”。
You add the .jar files you want to use in your projects build path. You access this windows by right-clicking your project. Choosing "Build path" -> "Configure build path".