我如何导入 org.apache.commons.lang3.ArrayUtils;进入 Eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30555847/
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-09-19 22:40:21  来源:igfitidea点击:

how do I import org.apache.commons.lang3.ArrayUtils; into Eclipse

javaeclipse

提问by Sizons

How do I import:

我如何导入:

org.apache.commons.lang3.ArrayUtils

org.apache.commons.lang3.ArrayUtils

library into a new project within the Eclipse Development Environment. Is there a package manager I can use or do I need to download a dll or binary and then reference it somehow within my codebase?

库到 Eclipse 开发环境中的一个新项目中。是否有我可以使用的包管理器,或者我是否需要下载一个 dll 或二进制文件,然后在我的代码库中以某种方式引用它?

I have seen similar questions but none really goes step by step to explain how one can import this library into Eclipse.

我见过类似的问题,但没有人真正一步一步地解释如何将这个库导入 Eclipse。

采纳答案by MJSG

First of all, you should have a Project. Right Click Eclipse Project from the Project or Package explorer

首先,你应该有一个项目。从项目或包资源管理器中右键单击 Eclipse 项目

Properties -> Java Build Path -> Libraries

属性 -> Java 构建路径 -> 库

From here select:

从这里选择:

  1. 'Add jar' if the jar is within your project
  2. 'Add external jar' if it is on your file system
  3. 'Add variable', if you have configured a variable in eclipse that points to the directory containing the jar files or the jar file itself (See how to configure variables below)
  4. 'Add library' if you have configured the jars into a library (see below for library configuration)
  5. 'Add class folder' if you just have a bunch of classes in a directory that should be used for classes/resources which is part of one of your projects
  6. 'Add class folder' if you just have a bunch of classes in a directory that should be used for classes/resources which is in your file system
  1. 如果 jar 在您的项目中,则“添加 jar”
  2. 如果文件系统上有“添加外部 jar”
  3. “添加变量”,如果您在 eclipse 中配置了一个指向包含 jar 文件的目录或 jar 文件本身的变量(请参阅下面的如何配置变量)
  4. 如果您已将 jars 配置到库中,则“添加库”(请参见下面的库配置)
  5. “添加类文件夹”如果您在一个目录中只有一堆类应该用于类/资源,这是您的一个项目的一部分
  6. “添加类文件夹”如果您的目录中有一堆类应该用于文件系统中的类/资源

Configuring variables:
Eclipse select menu: Window -> Preferences -> Java -> Build Path -> Classpath Variables

配置变量:
Eclipse选择菜单:Window -> Preferences -> Java -> Build Path -> Classpath Variables

Select New and give a Name and select a file or folder

选择新建并命名并选择一个文件或文件夹

Configuring libraries:

配置库:

Eclipse select menu: Window -> Preferences -> Java -> Build Path -> User Libraries -> New

Eclipse 选择菜单:Window -> Preferences -> Java -> Build Path -> User Libraries -> New

Provide a name and in that you can add jars from within a project or from the file system just like how it is mentioned above.

提供一个名称,您可以像上面提到的那样从项目或文件系统中添加 jar。



NOTE:In some cases, it might be convenient to allow build tools like gradle or maven or ant with ivy to manage your dependencies for a project (when i mean dependencies i mean libraries) as some project have about a few hundred jars as dependencies, and manually managing them might be painful. These build tools have the functionality of downloading the jars and its sources for you automatically by just adding an entry in a file and even caching it for later use.

注意:在某些情况下,允许诸如 gradle 或 maven 或 ant 和 ivy 之类的构建工具来管理项目的依赖项可能会很方便(当我指的是依赖项时,我指的是库),因为某些项目有大约几百个 jar 作为依赖项,手动管理它们可能会很痛苦。这些构建工具具有为您自动下载 jar 及其源代码的功能,只需在文件中添加一个条目,甚至将其缓存以备后用。

See https://gradle.org/for gradle
See https://maven.apache.org/for maven

https://gradle.org/gradle
https://maven.apache.org/maven