如何在 Eclipse 中将 .jar 添加到我的构建路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2727669/
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 can I add a .jar to my build path in Eclipse?
提问by Roman
I try to do it the following way:
我尝试通过以下方式做到这一点:
Right click on the name of the project.
Click on Build Path in the drop dawn menu.
Click on "Configure Build Path"
右键单击项目名称。
单击下拉黎明菜单中的构建路径。
点击“配置构建路径”
And then I do not know what to do. Should I select "Source", "Projects", "Libraries", "Order and Export"?
然后我不知道该怎么办。我应该选择“源”、“项目”、“库”、“订购和导出”吗?
In "Libraries" I have "Add JARs..." and "Add External JARs...". What should I select? (I have already a .jar file in the lib folder of my project.)
在“库”中,我有“添加 JAR...”和“添加外部 JAR...”。我应该选择什么?(我的项目的 lib 文件夹中已经有一个 .jar 文件。)
ADDED:
添加:
If I click on "Add JARs" in the "Libraries" tab, I see the "lib" sub-folder but if I go there I do not see my .jar file there (and I know that it is there).
如果我单击“库”选项卡中的“添加 JAR”,我会看到“lib”子文件夹,但如果我去那里,我在那里看不到我的 .jar 文件(我知道它在那里)。
回答by Christopher Klewes
- Right click on the jar you want to add.
Build Path
>Add to Build Path
- 右键单击要添加的 jar。
Build Path
>Add to Build Path
You're done.
你完成了。
If you want to add the Library with the Java Build Path
view, as you tried you have to use Add JARs
. If you copied the library via File System the Project is not in sync. You could press F5
on the selected Project.
如果您想在Java Build Path
视图中添加库,正如您所尝试的那样,您必须使用Add JARs
. 如果您通过文件系统复制库,则项目不同步。您可以按下F5
选定的项目。
If you edit outside of Eclipse a lot, you can enable auto-refresh by going to Window > Preferences
menu, then in the Preferences dialog box, select General > Workspace
.
Check the Refresh automatically
box.
如果您经常在 Eclipse 之外进行编辑,则可以通过转到Window > Preferences
菜单启用自动刷新,然后在“首选项”对话框中,选择General > Workspace
. 选中该Refresh automatically
框。
回答by gmhk
I think you are almost correct in adding the jar files to the Selected Project
我认为您将 jar 文件添加到 Selected Project 几乎是正确的
Right click on the name of the project.
右键单击项目名称。
Click on Properties in the menu.
单击菜单中的属性。
Click on "Java Build Path"
单击“Java 构建路径”
Then select "Libraries"
然后选择“库”
In "Libraries" Click "Add External JARs...".(if the jar files exists outside the project) Else Click "Add Jars" (if the jars Exists within the project)
在“库”中单击“添加外部 JAR...”。(如果 jar 文件存在于项目之外)否则单击“添加 JAR”(如果 jar 存在于项目中)
Once you do this, workspace builds automatically and after that your application is set to use for the development.
执行此操作后,工作区会自动构建,然后您的应用程序将设置为用于开发。
回答by leonm
Click "Add Jar" and select the jar from your project path.
单击“添加 Jar”并从项目路径中选择 jar。
回答by Ham Vocke
If the jar is already in you project directory click "Add jar" in the Libraries-tab. If not click "Add external jar". That should do it.
如果 jar 已经在您的项目目录中,请单击库选项卡中的“添加 jar”。如果没有,请单击“添加外部 jar”。那应该这样做。
If your jar does not show up when you click "Add jar" although you have copied it to your project directory you should refresh your project. Just go to your project explorer in eclipse, right click on the project-name and click "Refresh".
如果您的 jar 在您单击“添加 jar”时没有显示,尽管您已将其复制到您的项目目录,您应该刷新您的项目。只需在 Eclipse 中转到您的项目资源管理器,右键单击项目名称并单击“刷新”。