将 JAR 添加到 Eclipse Java 库

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

Adding a JAR to an Eclipse Java library

eclipsejar

提问by Paul Reiners

How do you add a JAR file to an already existing Java library in Eclipse? Note that this is not a user library.

如何将 JAR 文件添加到 Eclipse 中现有的 Java 库?请注意,这不是用户库。

That is, if you look at the Java Build Path for a Java project and click on the Libraries tab, you will see the list of libraries used by the project. If you expand a given library, you will see a list of JAR files included in that library. I want to add an additional JAR file to one of these libraries.

也就是说,如果您查看 Java 项目的 Java 构建路径并单击库选项卡,您将看到项目使用的库列表。如果展开给定的库,您将看到该库中包含的 JAR 文件列表。我想向这些库之一添加一个额外的 JAR 文件。

I am using Version 3.4.0 of Eclipse.

我正在使用 Eclipse 3.4.0 版。

采纳答案by idrosid

In Eclipse Ganymede (3.4.0):

在 Eclipse Ganymede (3.4.0) 中:

  1. Select the library and click "Edit" (left side of the window)
  2. Click "User Libraries"
  3. Select the library again and click "Add JARs"
  1. 选择库并单击“编辑”(窗口左侧)
  2. 点击“用户库”
  3. 再次选择库并单击“添加 JAR”

回答by Jla

In eclipse Galileo :

在日食伽利略中:

  • Open the project's properties
  • Select Java Build Path
  • Select Librariestab
  • 打开项目的属性
  • 选择Java 构建路径
  • 选择选项卡

From there you can Add External Jars

从那里你可以添加外部罐子

回答by Johnny Wey

You might also consider using a build tool like Maven to manage your dependencies. It is very easy to setup and helps manage those dependencies automatically in eclipse. Definitely worth the effort if you have a large project with a lot of external dependencies.

您还可以考虑使用像 Maven 这样的构建工具来管理您的依赖项。在 Eclipse 中设置并帮助自动管理这些依赖项非常容易。如果您有一个包含大量外部依赖项的大型项目,那么绝对值得付出努力。

回答by Osi

As of Helios Service Release 2, there is no longer support for JAR files.You can add them, but Eclipse will not recognize them as libraries, therefore you can only "import" but can never use.

从 Helios Service Release 2 开始,不再支持 JAR 文件。您可以添加它们,但 Eclipse 不会将它们识别为库,因此您只能“导入”但永远无法使用。