| | |

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

  • | | |

    Sending SMS using serialport in Java

    before going to execute this program read here  <a href="http://javamix.wordpress.com/2009/03/30/installing-comport-api-in-windows/">how to install comport api for windows</a> /*  this is the program used to send the message from javaprogram to the mobile phone */ /* Note :- before using this porogram  first read the post "serialport communication using Java" by me in this blog. */ package…

  • | |

    Read RSS feeds by Using Java

    /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author vijay * */ import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.CharacterData; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class RSSReader { private static RSSReader instance = null; private RSSReader() {…

  • | |

    Read RSS feeds using JSP

    <%@page contentType=”text/html”%> <%@page pageEncoding=”UTF-8″%> <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <%@page import=”java.net.URL”%> <%@page import=”javax.xml.parsers.DocumentBuilder”%> <%@page import=”javax.xml.parsers.DocumentBuilderFactory”%> <%@page import=” org.w3c.dom.CharacterData”%> <%@page import=” org.w3c.dom.Document”%> <%@page import=”org.w3c.dom.Element”%> <%@page import=”org.w3c.dom.Node”%> <%@page import=”org.w3c.dom.NodeList”%> <%@page import=”java.lang.*”%> <% String desc=null; try { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); URL u = new URL(“http://feed43.com/eenadu.xml”);   // feed address Document doc = builder.parse(u.openStream()); String title;…

  • | | |

    Finding the localhost IP

    // package sampleprograms; import java.io.*; import java.net.*; /** * * @author katta vijay */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here try{ String ip =  InetAddress.getLocalHost().getHostAddress(); System.out.println(ip); }catch(Exception e){ } } } —————————————————-output is———————— 10.0.0.223

  • | | | | |

    Calculating Latenciy in java and database

    calculating latencies ,  for a program , query or an service / project ., after little research here i am deriving mechanism to calculate latencies, first iam considering database : here my aim is calculate execution time for a query. >before executing the query run ‘set timing on’ comamnd in sql command line >after this…

Leave a Reply

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