简体   繁体   English

关于在 Eclipse 中添加库

[英]Regarding Adding libraries in Eclipse

In eclipse, I am trying to add some libraries.在 eclipse 中,我正在尝试添加一些库。 I choose "build path->configure build path->libraries".我选择“构建路径->配置构建路径->库”。 The right column of the "java build path" window gives me several options: Add JARS, Add External JARS, and Add Library. “java 构建路径”window 的右栏给了我几个选项:添加 JARS、添加外部 JARS 和添加库。

It seems to me that I should choose "Add Library", but what do the other two work for, "Add JARS" and "Add External JARS".在我看来,我应该选择“添加库”,但其他两个是做什么的,“添加 JARS”和“添加外部 JARS”。 What are the differences among these three options?这三个选项有什么区别?

Add Jars is for internal Jars - ie jars from your project workspace.添加 Jars 用于内部 Jars - 即来自项目工作区的 jars。 Add external Jars is for jars in a different directory on your hard drive - eg ones you downloaded or from a diff workspace.添加外部 Jars 用于 jars 在硬盘驱动器上的不同目录中 - 例如您下载的目录或从差异工作区。 This is the same as "Add Library" really, except that a library is a handy label for external jars that you add regularly.这实际上与“添加库”相同,只是库是您定期添加的外部 jars 的方便 label。 See http://www.javaprogrammingforums.com/java-code-snippets-tutorials/6536-javatip-dec-18-2010-eclipse-user-libraries.html for an example of how to add.有关如何添加的示例,请参阅http://www.javaprogrammingforums.com/java-code-snippets-tutorials/6536-javatip-dec-18-2010-eclipse-user-libraries.html

Add Library allows you to add a library defined in your Eclipse coniguration.添加库允许您添加在 Eclipse 配置中定义的库。 If you check a project into a source control system and somebody checks it out, it would compile only if that developer has corresponding Eclipse libraries configured.如果您将项目签入源代码控制系统并且有人将其签出,则只有当该开发人员配置了相应的 Eclipse 库时,它才会编译。

Add JARs allows to add jar files that are located in a subdirectory of your project's directory, usually named lib.添加 JARs 允许添加 jar 文件,这些文件位于项目目录的子目录中,通常命名为 lib。 You would check these jars into your source control system with your project and everyone who checks the project out would have these libraries.您可以将这些 jars 与您的项目一起检查到您的源代码控制系统中,并且每个签出项目的人都会拥有这些库。

Add External JARs is the least useful approach.添加外部 JARs 是最没用的方法。 It adds dependencies to the jar files of libraries located elsewhere on your computer and it hardcodes the pathnames of these files.它将依赖项添加到位于计算机其他位置的库的 jar 文件中,并对这些文件的路径名进行硬编码。 If you check the project into a source control system and somebody checks it out, it would build only if they have the same libraries in the exact same places.如果您将项目签入源代码控制系统并且有人将其签出,则只有当他们在完全相同的位置具有相同的库时,它才会构建。 Forget about teams using a mix of Windows, Mac and Linux workstations!忘记使用 Windows、Mac 和 Linux 工作站的团队吧!

'Add JARS' allows you to add JARs that are resident in the workspace to the project build path. “添加 JARS”允许您将驻留在工作区中的 JARs 添加到项目构建路径中。

'Add External JARS', well, allows you to add JARs that are resident outside the workspace. “添加外部 JARS”允许您添加驻留在工作区外部的 JARs。 You can add JARs that are inside the workspace, but the above option is meant to perform that.您可以在工作空间内添加 JARs,但上述选项旨在执行该操作。

Libraries, on the other hand, refer to the various predefined libraries in Eclipse.另一方面,库是指 Eclipse 中的各种预定义库。 A library is usually an organized collection of JARs.一个库通常是一个有组织的 JARs 集合。 It could refer to:它可以指:

  • the JRE System library, consisting of JARs in the JDK/JRE used for building the project JRE 系统库,由用于构建项目的 JDK/JRE 中的 JARs 组成
  • a Java EE Server Runtime, made available through an installation of a WTP adapter for a server Java EE 服务器运行时,通过为服务器安装 WTP 适配器提供
  • User Libraries (that can be created by the user)用户库(可由用户创建)
  • JDBC Connectivity Driver Definitions JDBC 连接驱动程序定义
  • Libraries that ship with Eclipse, like JUnit 3.x, 4.x.随 Eclipse 提供的库,例如 JUnit 3.x、4.x。

Adding a Library adds all the entries specified in the library definition to the build path.添加库会将库定义中指定的所有条目添加到构建路径。

  • Add Jars Lets you point to jars contained within your project.添加 Jars 让您指向项目中包含的 jars。

  • Add External Jars Lets you point to jars anywhere on the file system.添加外部 Jars 让您指向文件系统上的任何位置 jars。

  • Add Library Lets you point to a set of jars you have pre defined.添加库 让您指向您预先定义的一组 jars。

Have a look at this eclipse documentation - especially the Libraries tab section.看看这个eclipse 文档——尤其是库选项卡部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM