I struggled until I read this article.
Other IDEs have you define the executable jar, its source code jar or folder, and its JavaDoc jar or folder simultaneously as all equal parts of one named library. The eclipse way is different. Instead of 3 parts to one library, Eclipse establishes a hierarchy of the library (just a name), one or more executable jars, and then attaching the source code and JavaDoc as attributes on each executable jar.
So, the steps to establish a library:
- Establish the name of the library.
On a Mac, that would be Eclipse > Preferences > Java > Build Path > User Libraries > New.
- Add a jar.
This would be the executable jar of the utility.
For example, with JodaTime: joda-time-1.6.2.jar
- Notice the 4 sub-items that appear below the added jar:
- Source attachment:
- Javadoc location:
- Native library location:
- Access rules:
- Select ‘Source attachment:’ and click Edit.
For example, with JodaTime: joda-time-1.6.2-sources.jar
- Do similarly if you have Javadoc available.
For example, with JodaTime: joda-time-1.6.2-javadoc.jar
- Click OK to close the prefs.
- Context-click your project in the Package Explorer.
- Choose Build Path > Add Libraries
- Choose ‘User Library’ and click ‘Next’.
- Check the libraries that you want to add.
The libraries appear as items inside your project in the Package Explorer.