将 Java 库导入 Eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19136191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 14:25:16  来源:igfitidea点击:

Import Java library into Eclipse

javaeclipseimport

提问by the_critic

I would like to create a test project in Eclipse. My goal is to add AND USE all the class files from the library. How would I do that ? It's this particular library https://github.com/twitter/hbc. I know how to import class files in XCode (Mac/iOS), but whenever I worked with Eclipse it has always been the import which produced the most problems and shied me away. I have tried to drop the master folder into a newly created java-project, however I am not quite sure how to import them (especially because of the folder structure of the library).

我想在 Eclipse 中创建一个测试项目。我的目标是添加和使用库中的所有类文件。我该怎么做?这是这个特定的库https://github.com/twitter/hbc。我知道如何在 XCode (Mac/iOS) 中导入类文件,但是每当我使用 Eclipse 时,它​​总是产生最多问题并让我避开的导入。我试图将主文件夹放入新创建的 java 项目中,但是我不太确定如何导入它们(特别是因为库的文件夹结构)。

采纳答案by Simulant

right click on your project -> Build Path -> Configure Build Path... On Tab Libraries -> Add JARs... -> select your library .jar file. (must be visible within your workspace, best added to a lib-folder within your project).

右键单击您的项目 -> 构建路径 -> 配置构建路径...在选项卡库 -> 添加 JARs... -> 选择您的库 .jar 文件。(必须在您的工作区中可见,最好添加到项目中的 lib 文件夹中)。

otherwise install the Maven Integration for Eclipse plugin and make your project a maven managed project: Help -> Eclipse Marketplace... -> search m2e -> scroll down -> install.

否则,安装 Maven Integration for Eclipse 插件并使您的项目成为 Maven 管理的项目:帮助 -> Eclipse Marketplace... -> 搜索 m2e -> 向下滚动 -> 安装。

Maven is a Build tool that helps your managing your dependencies. You add your dependency to a library as a short xml text in the pom.xml file and maven downloads and links the library to your project automatically. Read more about it in the documentation.

Maven 是一个构建工具,可帮助您管理依赖项。您将依赖项作为 pom.xml 文件中的简短 xml 文本添加到库中,maven 会自动下载库并将其链接到您的项目。在文档中阅读更多相关信息。