Java 如何将源目录放在eclipse中的构建路径中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18768861/
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 to place source directory in build path in eclipse
提问by Ford Perfect
I mostly use JAR files when I want to use any particular library. I place it in the WEB-INF/lib of my project folder.
当我想使用任何特定的库时,我主要使用 JAR 文件。我把它放在我的项目文件夹的 WEB-INF/lib 中。
But if for some reason a library only makes its source available and not the JAR then how would I proceed rightly.
但是,如果出于某种原因,一个库只提供其源代码而不是 JAR,那么我将如何正确进行。
Do I convert it to JAR file using some software? (which one do you find good if this is the case) Or is there a way to also add src folder?
我是否使用某些软件将其转换为 JAR 文件?(如果是这种情况,你觉得哪个好)或者有没有办法也添加 src 文件夹?
采纳答案by dkatzel
right click on the project, go to Java Build Path and then:
右键单击项目,转到 Java Build Path,然后:
1) if you have the only the .java files and need to compile it then click on the "Source" tab and select "Add Folder" which will bring up a folder chooser dialog. when the source folder is added, then eclipse will compile it and put the classes in the default output folder along with your other source code.
1) 如果您只有 .java 文件并且需要编译它,则单击“源”选项卡并选择“添加文件夹”,这将显示文件夹选择器对话框。添加源文件夹后,eclipse 将编译它并将类与其他源代码一起放在默认输出文件夹中。
2) if you already have the .classes in a folder somewhere you can click on the "Libraries" tab and then click either "Add Class Folder" or "Add External Class Folder". I've never actually used this option but that would appear to be what you want.
2) 如果您已经在某个文件夹中拥有 .classes,您可以单击“库”选项卡,然后单击“添加类文件夹”或“添加外部类文件夹”。我从来没有真正使用过这个选项,但这似乎是你想要的。
回答by Nambi
You can add a jar in eclipse by right clicking on the
您可以通过右键单击在 Eclipse 中添加一个 jar
Project --> Build Path --> Configure Build Path.
under source add folder or link source
在源下添加文件夹或链接源