| | |

Difference between java jar and war

Both JAR and WAR are created(Zipped) with Java JAR tool , both have different purposes.

JAR  – Java Archive this JAR file may be a standalone java application or a zipped source . this file contains classes , libraries , property files

Command to create a JAR file :

here i want to create JAR file contains Test.class

Step 1:

Goto CMD –> you file (Test.class) location

Step 2:

Run the following command

jar cf “javamix”.jar  Test.class  // here javamix is my JAR file name , Test.class is my file

Step 3:

check the jar file , weather it is created or not

Note : here you can pack ‘n’ no of classes/files to a single jar file .

 

WAR  – web application archive (WAR)

this web archive contains web application that can be ready to deploy in servers(tomcat,jboss,etc..) this file contains servlets/jsp,classes,html files , scripts and dependent libraries etc

Procedure to create a WAR file :

here JAR wont create .class files for your java file , first we have to create class files then create WAR file .

Step 1:

Goto CMD –>go to your folder location where you have all the files

Step 2 :

jar -cvf  javamix.war *

which means compress all the files in this directory  into javamix.war file

C create ,V Verbose,F file

 

 

 

 

 

 

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *