Monday, March 18, 2013
How to Make Jar, War and Ear Files in Easy Steps
In software development programming are written in component level and components are integrate at final stage of development. This Stage requires packaging for various components (files) into one package. I am going to discuss three packaging format for java programming language but before makes your hand dirty let me introduce all three formats:
JAR (Java ARchive) is an archive file format typically used to aggregate many Java class files and associated metadata and resources (text, images and so on) into one file to distribute application software or libraries on the Java platform
A WAR file (or Web application ARchive) is a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static Web pages (HTML and related files) and other resources that together constitute a Web application.
EAR (Enterprise ARchive) is a file format used by Java EE for packaging one or more modules into a single archive so that the deployment of the various modules onto an application server happens simultaneously and coherently. It also contains XML files called deployment descriptors which describe how to deploy the modules.
Process of making Jar, war and Ear file:- Suppose you have a folder named “Ripe” in “F” drive of your computer in which you have text, source code(.java), generated code(.class) files and you want to make War/Jar/Ear of all data or selected file in that particular folder. Now follow these steps:-
1-Open your computer command prompt (cmd) and type f: to change drive then give path inside your folder by type this cd Ripe and hit enter. This will set your cmd path to your folder in which you want to create your file. See the screen shot below:
2-Assume that your file name is “tech” which you are going to make.
3- Now, For Jar file type jar cvf tech.jar *.* hit enter and you would find war file in your Ripe folder. See the screen shot below:
4- For War File, Type- jar cvf tech.war *.* hit enter and done. See the screen shot below.
5-For Ear File, Type- jar cvf tech.ear *.* hit enter. See the screen shot.
You can choose particular file format from your folder by enter file format like *.java or *.class or *.txt instead of *.* in command prompt .*.* means all files inside the folder.