Reputation: 7477
I am completely new to Java development so bear with me...
I have downloaded the Joda time library which consists of three files:
Firstly, how do I use this library in one of my own NetBeans projects?
Secondly, generally speaking, what is the distinction between the three files above? What do the labels 'javadoc' and 'sources' signify? How are these jars different from the 'joda-time-1.6.jar' library?
Many thanks for any help.
Upvotes: 19
Views: 70075
Reputation: 51965
You would add the JAR file to the Libraries in your project:
(source: netbeans.org)
As for the different JARs,
Upvotes: 31
Reputation: 205885
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:
Upvotes: 15
Reputation: 45593
If it is a maven base project the above will not work and you should use : build maven project with propriatery libraries included
Upvotes: 2
Reputation: 9902
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.
Upvotes: 5
Reputation: 297
When you create a new project there is a library folder in the project viewer. Right click on that and pick the add jar file option. Once you add the joda-time-jar you can associate either the sources or the javadoc jar with that joda-time.jar. Associating the source or the java doc allows netbeans to provide intellisense.
Upvotes: 4