简体   繁体   English

如何在Eclipse中的构建路径中放置源目录

[英]How to place source directory in build path in eclipse

I mostly use JAR files when I want to use any particular library. 当我想使用任何特定的库时,我主要使用JAR文件。 I place it in the WEB-INF/lib of my project folder. 我将其放在项目文件夹的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? 是否可以使用某些软件将其转换为JAR文件? (which one do you find good if this is the case) Or is there a way to also add src folder? (如果是这种情况,您觉得哪一个很好)还是有办法也添加src文件夹?

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. 1)如果只有.java文件并且需要编译,请单击“源”选项卡,然后选择“添加文件夹”,这将弹出一个文件夹选择器对话框。 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. 当添加源文件夹时,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". 2)如果您已经将.classes保存在某个位置的文件夹中,则可以单击“库”选项卡,然后单击“添加类文件夹”或“添加外部类文件夹”。 I've never actually used this option but that would appear to be what you want. 我从未真正使用过此选项,但是这似乎正是您想要的。

You can add a jar in eclipse by right clicking on the 您可以通过右键单击

Project --> Build Path --> Configure Build Path. 

under source add folder or link source 在源下添加文件夹或链接源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM