Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use .jar files in NetBeans?

Tags:

java

jar

netbeans

I am completely new to Java development so bear with me...

I have downloaded the Joda time library which consists of three files:

  • joda-time-1.6.jar
  • joda-time-1.6-javadoc.jar
  • joda-time-1.6-sources.jar

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.

like image 850
MalcomTucker Avatar asked Dec 29 '09 18:12

MalcomTucker


People also ask

How do I add a JAR file to NetBeans 12?

In the project properties window, click on the Libraries node at the left Categories pane. Then on the right side, click on the Run tab and then click on the Add JAR/Folder button and browse the external JAR files you want to add, as shown in the below image. Then click on the OK button.

How do I run a .JAR file?

To run an application in a nonexecutable JAR file, we have to use -cp option instead of -jar. We'll use the -cp option (short for classpath) to specify the JAR file that contains the class file we want to execute: java -cp jar-file-name main-class-name [args …]


1 Answers

You would add the JAR file to the Libraries in your project:

alt text
(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
like image 70
Kaleb Brasee Avatar answered Oct 22 '22 04:10

Kaleb Brasee