2011-07-09

Being new to Eclipse, I could not figure out how to add libraries to my project. By libraries, I meant already-compiled jars, such as JodaTime, SLF4J, Postgres JDBC driver, etc. And I want to provide Eclipse with access to those utilities’ source code and JavaDoc if available.

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