How to create Jar file for project in java with the help of Command Prompt or Netbeans IDE

In this article I will explain the how to create a Jar file for projects in java. To create Jar file two method is  explain, first is by using command prompt and second is Netbeans IDE.
The explanation with the help of screen shoots and also with video tutorial. With the help of this article you can easily create a Jar file for your project which is in Java language.
In this article I also explain  “What is the need to create a jar file”.
Jar file stands for Java Archive. Jar file extension is *.jar. A Jar file is a archive of java classes or library classes is archived with metadata of resources used in project just like images, texts and other media.
The main question is arise in mind is the “What is the need to create a jar file for project?”. The answer is simple that the jar file allows us to run a java classes and associated resource in efficient way on java run time environment.
And also we don’t need to run the java classes with the help of command prompt because of the in windows operating systems Java 2 Run time Environment’s is associated with *.jar extension and it automatically  run it with javaw -jar. Also in Solaris operating system a special magic number is used to recognize the jar file. So to run your project only need is the double click on the Jar file of your project. 
And the Jar file save the disk space because of the it use the compression techniques to combined the all classes and other resources.
To create a Jar file two method is as following:
First Method:
                     In first method to create Jar file we use command prompt. If you have sufficient knowledge of command prompt then you can use this method to create Jar file.
To use this method at first set the path to include JDK bin. To set path for JDK use this command C:> path c:Program FilesJavajdk1.5.0_09bin;%path%
Here pink color is the path of installed jdk directory of bin folder. To confirm the path is successfully set or not use this command C:> java -version
If this command shows the following output then you successfully set the path.


java version command or check path set or not

After that compile the all java files of your project and put all the classes and other resources in folder or sub folders.
C:> javac *.java

and goto your folder where all the classes and resources  with help help of cd command.
After that the we need to create a manifest file.

to create manifest file use following command.
C:YourProjectDirectory> echo Main-Class: YourProjectIDirectory>manifest.txt

Now you can create a Jar file by using following command.

C:YourProjectDirectory> jar cvfm ApplicationName.jar manifest.txt *.class
here pink color value is the name of your jar file.

Second Method:
In second method create a Jar file by using the Netbeans IDE.

This method is very easy and no need the any knowledge of command prompt.
In this method you only need the Netbeans IDE.
The Netbeans IDE you can download from http://netbeans.org/

To create Jar file using Netbeans install the Netbeans in your operating system and use the following procedure.

At first open your netbeans IDE and create a new project in file menu.
The following window is opened fill the information and click on finish.

New Project window in netbeans IDE
New Project name location choose window of Netbeans IDE

After that put the all java files in project folder and Start point of application is in Main.java file.
and then click on the “Build Main Project” in Run menu Or press F11 key. This process create the Jar file of your project. The Jar file is in dist folder of your project.
If you face any problem then you can also view video tutorial of creating jar files.