deprecated
deprecated

Reputation: 5242

Linking source to .jars in Eclipse

This framework distribution includes a lib folder (where all the binary .jars are) and a src one (where you can find the corresponding .javas for each .jar). So far I only have added lib to the Java project build path.

How would you copy src now? Just adding it or is there a way of somehow link it to lib? I don't have in mind what the gain would exactly consist of but I reckon that that would be somewhat better.

Edit - src is provided as a folder hierarchy, not source .jars.

Upvotes: 0

Views: 2179

Answers (2)

Eric
Eric

Reputation: 510

I'm not 100% sure this is what you're looking for, but if you have added jars to your build path, you can right click on individual jars in the Project Explorer and select Properties. In the resulting pop-up is a Java Source Attachment tab, which has options for linking source files depending on where they're located.

The main advantage to this that I'm aware of is when you're debugging code that makes use of the jars. If you have source attached, you can step through the code, including comments (which are not available if you use a de-compiling tool to step through classes for which you don't have source).

Upvotes: 1

Ed Staub
Ed Staub

Reputation: 15690

If you're not modifying the source, performance will be better if the source for each jar is in its own source jar. It's usually also more convenient. This is a convention at this point - especially if you can get the jars from a maven repository. Each jar should be organized as you'd expect, with top level directory(s) "org", "com", etc. In the build path, you can attach a source jar to each binary jar.

Upvotes: 1

Related Questions