Difference Between JAR and WAR
JAR vs WAR
The first thing a non-technical person needs to understand is that JAR and WAR are types of files. They are used to package different modules and have different functions. People who already know about these files are sometimes confused as to their different functionalities. They are archived files and are commonly used and created for web applications and holding many files together.
JAR files are an acronym for “Java Archive” files; WAR files are an acronym for “Web Application Archive” files. The functionality of these files are different, and in application of J2EE, the packaging of modules is either as WAR or JAR based on their functionality.
JAR files allow the aggregation of multiple files into a single file. They are commonly used in a library to hold the Java classes or utility along with some files which are static like videos and images. It is usually for easier accessibility. Whereas WAR files may store Java classes, XML, and Java Server pages for different applications of the web.
The EJB module is packaged as JAR files. This module contains EJB descriptor and Java beans class files. These are packaged with a .jar extension; whereas the web module is packaged as WAR files. This module contains JSP files, Servlet class files, Supporting files, HTML, and GIF. They are packaged as a .war extension.
WAR files are used for web applications. They are deployed to a JSP engine or to a servlet. The WAR file also has a WEB–INF directory, the WEB.xml which is the deployment descriptor sits at the directory; whereas the JAR files are underneath the WEB-INF/classes directories and WEB-INF /lib.
Summary:
1.The main difference between JAR files and WAR files is that one can package many different things in JAR files. It is most commonly used to package Java classes, but a lot of other things can be packaged as well. However, WAR files are specifically for web applications.
2.JAR files can be created with any format and directory of your choice; whereas WAR files are created from Servlets. 3.They have a specific format; they have specific directories and files. The WAR files have a WEB-INF directory, WEB-INF/lib directory, WEB-INF/web.xml, and WEB-INF/classes directory.
4.The acronym of “JAR” files is “Java Archive” files; whereas the acronym of “WAR” files is “Web Application Archive” files.
5.The JAR files are packaged with a .jar extension; whereas WAR files are packaged with a .war extension.
6.EJB modules are packaged as JAR files. This module contains an EJB descriptor and Java beans class files; whereas web modules are packaged as WAR files which contain JSP files, Servlet class files, supporting files, GIF, and HTML.
- Difference Between Data Mining and Data Warehousing - October 21, 2012
- Difference Between 7-Keto DHEA and DHEA - October 20, 2012
- Difference Between Tamil and Malayalam - October 18, 2012
Search DifferenceBetween.net :
Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.
Excellent explanation.