javaeclipsejar

How to place source directory in build path in eclipse


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.

But if for some reason a library only makes its source available and not the JAR then how would I proceed rightly.

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?


Solution

  • right click on the project, go to Java Build Path and then:

    1. If you only have the .java files and need to compile them, 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.

    2. If you already have the .class files 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.