How to use .jar files in NetBeans?
You would add the JAR file to the Libraries in your project:
(source: netbeans.org)
As for the different JARs,
- joda-time-1.6.jar just contains the compiled classes (this is the JAR you need in order to use Joda in your project)
- joda-time-1.6-javadoc.jar contains the documentation for all the classes
- joda-time-1.6-sources.jar contains the source code for all the classes
In addition to adding JARs or Folders directly to your project, you can add them to the Library and share them among multiple projects. From the Tools menu choose Libraries to get a dialog for adding libraries. Once added, they can be selected from the Add Library... context menu, as shown in Kaleb Brasee's answer. Note, for example, the additions of H2 Database, JFreeChart and JScience:
There are many ways to use a .jar file in NetBeans. Kaleb and trashgod have covered two of them. The important thing to do is figure out which is right for you.
If you have a random jar file that has functionality that you want to use in your project, the 'Add Jar/Folder...' option can be a good choice. Your project will become dependent on that jar file. If you start to share the project with other folks, they will need to have that jar to compile the code.
When you add a jar file to the project, the NB Java editor will be able to take advantage of it and provide code completion (display method signatures in a popup that you can select).
Taking the extra time to create a Library for the Joda Time may be a better choice in this particular case. By creating a library, you can associate the javadoc with the functionality. This makes code completion in the NB editor even more useful, since NB will show you the javadoc associated with the method signatures that you can select. Good javadoc will help you decide which method is really the right one for you. You can also associate the source of the library with the jar. This becomes very useful when you start to debug code, since you will be able to 'step into' the library code. These are great additional features that are not supported by using the 'Add Jar/Folder...' option.
Creating a library does have some disadvantages, though...
Folks that want to compile your code would need to create a similar Library, which will be a bit more work.