如何将所有引用的库导入 Eclipse 中的文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4406112/
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
How do I import all the referenced libraries to my folder in Eclipse?
提问by wizztjh
When I pack the code in Java in JAR form, will those referenced libraries in Eclipse be packed inside also?
当我将Java中的代码以JAR形式打包时,Eclipse中引用的那些库也会打包进去吗?
I have run into a tutorial that use import > general > file system to import JAR files instead of external JAR files. Are there any differences?
我遇到了一个使用 import > general > file system 来导入 JAR 文件而不是外部 JAR 文件的教程。有什么区别吗?
回答by Thilo
When you export a runnable jar file (using the Export wizard), there is an option to include all dependencies. This is not the default, and it requires some class-loading magic (which Eclipse takes care of under the hood), but if you do that, Eclipse does include all jar files your code depends on and you end up with a standalone jar file. If you create a normal jar file (runnable or not), no dependencies are included.
当您导出可运行的 jar 文件(使用导出向导)时,可以选择包含所有依赖项。这不是默认设置,它需要一些类加载魔法(Eclipse 在幕后负责),但如果你这样做,Eclipse 会包含你的代码所依赖的所有 jar 文件,你最终会得到一个独立的 jar 文件. 如果您创建一个普通的 jar 文件(可运行或不可运行),则不包含任何依赖项。
回答by Ravi Parmar
Yes, you can right click on Project --> Property --> Java buildpath --> and select library tab and select "Add jar" or "Add External java " into lib folder...
是的,您可以右键单击项目 --> 属性 --> Java 构建路径 --> 并选择库选项卡,然后选择“添加 jar”或“添加外部 java”到 lib 文件夹中...
So, it is a very good way to put all libraries into the lib
folder in your project.
因此,将所有库放入lib
项目中的文件夹是一种非常好的方法。
Or you also can add a new reference library at a time when you create your new project.
或者,您也可以在创建新项目时添加新的参考库。