Java 将文件夹添加到 Eclipse 类路径

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

Adding folder to Eclipse classpath

javaeclipse

提问by Paul

While developing a Java project, I place all of my jar files in a folder, created within my project, called libs.Now, is there a way to add my libsfolder to the Java class path so that I do not have to add each individual jar?

在开发 Java 项目时,我将所有 jar 文件放在一个文件夹中,该文件夹在我的项目中创建,名为libs.Now,有没有办法将我的libs文件夹添加到 Java 类路径中,这样我就不必添加每个单独的 jar 了?

I was thinking something along the lines of a variable or creating a user library.

我在想一些类似变量或创建用户库的事情。

采纳答案by brabster

Based on what you've said, I would probably create a user library containing your library JARs.

根据您所说的,我可能会创建一个包含您的库 JAR 的用户库。

You can create a User Library with Window => Preferences, drill down to Java => Build Path => User Libraries. => Then choose New, and give your library a name => Then add the JARs you want.

您可以使用 Window => Preferences 创建一个 User Library,深入到 Java => Build Path => User Libraries。=> 然后选择新建,并为您的库命名 => 然后添加您想要的 JAR。

Then you can add all the JARs to the classpath of any project you have by right-clicking on the project => Add Libraries => User Libraries, and selecting your library.

然后,您可以通过右键单击项目 => 添加库 => 用户库,然后选择您的库,将所有 JAR 添加到您拥有的任何项目的类路径中。



Update; to have Eclipse dynamically add .jar files you drop into a folder to your project classpath, you need a plugin called Library Folder ClasspathContainer. Follow these instructionsand you're in business.

更新; 要让 Eclipse 动态地将放入文件夹的 .jar 文件添加到项目类路径中,您需要一个名为Library Folder ClasspathContainer的插件。遵循这些说明,您就可以开展业务了。