Java is a general-purpose, high-level programming language used to develop multi-domain applications and is popular due to multiple reasons. Java source code is compiled into intermediate code called bytecode. Any platform with a Java Virtual Machine (JVM) can execute this bytecode. Therefore, Java is platform independent. Furthermore, Java is robust, secure, and multi-threading friendly. Two types of files related to Java programming are JAR and WAR.
Key Areas Covered
1. What are JAR files?
– Definition, Functionality
2. What are WAR files?
– Definition, Functionality
3. What is the difference between JAR and WAR files?
– Comparison of key differences
JAR, Java, JVM, WAR
What are JAR files?
A JAR file is a file that contains all the components to make a stand-alone executable Java application. Also, a JAR file includes compiled Java source code, manifest file, XML-based configuration data, JSON-based data files, images, and audio. It is an aggregation of all these files into a single compressed file. Compressing all files helps to reduce the size of the application. Also, it makes it easier to move the JAR file over the network between different platforms.
Figure 1: Add Java files
Each Java Development Kit (JDK) includes a JAR utility to support JAR files. Allows you to create new JAR files with a manifest file and extract the entire contents of a JAR file to the file system. Also, the JAR utility helps to update existing JAR files.
What are WAR files
Figure 2: JSP Web Application
There are two methods to deploy a WAR file: by using the server’s control panel or by manually having the war file in a specific folder on the server. If the developer wants to deploy a WAR file to a server like Apache Tomcat manually, he can go to the Tomcat webapps directory and paste the WAR file into that directory. Otherwise, when you run the web project, the server extracts the WAR file internally.
Difference between JAR and WAR files
A JAR file is a file with Java classes, associated metadata and resources like text, images added in a file. A WAR file is a file that is used to distribute a collection of JAR files, JSPs, Servlets, XML files, static web pages such as HTML, and other resources that make up a web application. Thus, this explains the main difference between JAR and WAR files.
JAR file stands for Java Archive. WAR file stands for Web Application Resource or Web Application Archive.
Also, a JAR file has a .jar file extension, while a WAR file has a .war file extension.
Its use attributes to another difference between JAR and WAR files. Namely; a JAR file allows the Java Runtime Environment (JRE) to deploy an entire application, including classes and associated resources, in a single request. On the other hand, a WAR file allows you to easily test and deploy a web application.
1. “JAR (Archive Format)”. Wikipedia, Wikimedia Foundation, August 26, 2018, Available here.
2. “What is JAR file (Java archive)? – Definition of WhatIs.com. ”TheServerSide.com, Available here.
3. “WAR (File Format)”. Wikipedia, Wikimedia Foundation, July 13, 2018, Available here.
1.”Glpk for Java Eclipse Project Properties” By Xypron – Own work (CC BY-SA 3.0) via Commons Wikimedia
2.”JSPLife” By User:Zedlander, User:Sae1962 – (CC BY-SA 3.0 ) via Commons Wikimedia