Updating an existing .jar file

I have downloaded the .class files of servlet2.3 . I have successfully archived the .class files which is under javax.servlet.* package.However, i am unable to understand how do i add the .class files which are under javax.servlet.http. package to the same archive.
Where do i place the already created .jar file. Please give me the exact syntax.
I placed my .jar file under http folder and ran the command jar cvfu Servlet.jar *.class but it did not work.
Thanks!
Jayashree

I assume that there is :
- a jar file that you wanna update with a newer class file
- a class file that you wanna use to update the jar file
you must copy the yourjarfile.jar in your home directory :
cp anydirectory/yourjarfile.jar /home/yourdirectory/
then you must uncompress it by :
cd /home/yourdirectory
jar -xf yourjarfile.jar
then you must copy the newer class file that you have compiled in the good subdirectory that has been created while uncompressing yourjafile.jar
cp directorywhereyouclassfileis/yourclassfile.class subdirectorycreatedwhileuncompressing/
then you can update you jar file by :
jar -uf directorycreatedwhileuncompressing/yourclassfile.class yourjarfile.jar
You can then verify that is has just been updated by :
jar -tvf yourjarfile.jar -->verify the date/time to check
hope it helps...
bye

Similar Messages

  • How to set new value for the existing jar file

    Help:
    I am wondering if there is a simple to update value for Manifest-Version in a existing jar file?
    Thanks!

    The jar command's -u option is about as easy as I know.
    See the jar command documentation for the details.

  • How do i update an existing XML File?

    Hello, I have the following xml file gps.xml:<?xml version="1.0"?>
    <!DOCTYPE gps SYSTEM "gps.dtd">
    <gps>
       <latitude>43.00000</latitude>
       <longitude>-83.00000</longitude>
    </gps> I already have methods written to get the values. But how can I change these values and update the file to reflect these changes?
    thanks for your help!

    Hi, I already have this following code. I would just like to add a method to it to update the existing XML file with different lat/lon coordinates. Could you please help me out with it? thanks
    import java.io.*;
    import java.io.PrintWriter;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    public class Gps implements java.io.Serializable {
        private double latitude_;
        private double longitude_;
        public Gps(Document doc) {
            setup(doc.getDocumentElement());
        public Gps(String uri) throws IOException, SAXException, ParserConfigurationException {
            setup(uri);
        public void setup(Document doc) {
            setup(doc.getDocumentElement());
        public void makeElement(Node parent) {
            Document doc;
            if (parent instanceof Document) {
                doc = (Document)parent;
            } else {
                doc = parent.getOwnerDocument();
            Element element = doc.createElement("gps");
            int size;
            URelaxer.setElementPropertyByDouble(element, "latitude", this.latitude_);
            URelaxer.setElementPropertyByDouble(element, "longitude", this.longitude_);
            parent.appendChild(element);
         public Document makeDocument() throws ParserConfigurationException {
            Document doc = UJAXP.makeDocument();
            makeElement(doc);
            return (doc);
        public final double getLatitude() {
            return (latitude_);
        public final void setLatitude(double latitude) {
            this.latitude_ = latitude;
        public final double getLongitude() {
            return (longitude_);
        public final void setLongitude(double longitude) {
            this.longitude_ = longitude;
       public final void updateXmlFile(double latitude, double longitude) {
         // something???
        public final void updateXmlFile(double latitude, double longitude) {
            this.latitude_ = latitude;
            this.longitude_ = longitude;
        public String makeTextDocument() {
            StringBuffer buffer = new StringBuffer();
            makeTextElement(buffer);
            return (new String(buffer));
        public void makeTextElement(StringBuffer buffer) {
            int size;
            buffer.append("<gps");
            buffer.append(">");
            buffer.append("<latitude>");
            buffer.append(Double.toString(getLatitude()));
            buffer.append("</latitude>");
            buffer.append("<longitude>");
            buffer.append(Double.toString(getLongitude()));
            buffer.append("</longitude>");
            buffer.append("</gps>");
        public String toString() {
            try {
                return (makeTextDocument());
            } catch (Exception e) {
                return (super.toString());
    }

  • Modifying existing jar file, how?

    Hi there,
    I have a problem trying to modify an existing jar file. When I want to create a jar file, I use something like:
    REM build the application on windows, assuming the java/bin
    REM directory is in the path environment variable
    REM application is just the directory I am using
    SET cp = c:\application\TestApp
    javac -classpath %cp% TestApp.java
    REM ****************************************
    REM do packaging and adding manifest
    REM ****************************************
    jar cvfm App.jar manifest.mf TestApp*.class
    REM ****************************************
    REM run the jar file
    REM ****************************************
    javaw -jar App.jar
    But now, I have an existing jar file (swingall.jar) and I want to modify a class within that file. So, I modified the .java file, and compiled it to get my new class file.
    And the question is, how do I modify the existing file, so that I keep everything the same, except the modified class?
    Thanks
    Fernando

    I have just found out that I can't use "u". It seemsthat's only
    possible with older versions of jar.Huh? I'm using the 1.4.2-b28 jdk, it's still there,
    and I don't see how it could ever possibly be
    removed.
    Type:
    jar
    with no arguments to see all the options to jar.I already did, to double check it, and this is what I got:
    C:\Documents and Settings\Fernando Sanz>jar
    Usage: jar {ctx}[vfm0M] [jar-file] [manifest-file] files ...
    Options:
    -c create new archive
    -t list table of contents for archive
    -x extract named (or all) files from archive
    -v generate verbose output on standard error
    -f specify archive file name
    -m include manifest information from specified manifest file
    -0 store only; use no ZIP compression
    -M Do not create a manifest file for the entries
    If any file is a directory then it is processed recursively.
    The manifest file name and the archive file name needs to be specified
    in the same order the 'm' and 'f' flags are specified.
    Example: to archive two class files into an archive called classes.jar:
    jar cvf classes.jar Foo.class Bar.class
    Note: use the '0' option to create a jar file that can be put in your CLASSPATH
    Thanks for trying with jdk 1.4, I don't have it installed in my computer right now, so I'll try tomorrow with another computer at Uni.
    Thanks!

  • Updating an existing  xml file in java

    Hi,
    i need to update an existing xml file with new nodes. But i don.t know how to do that. i can read and write a new xml file . But updaton seems too difficult for me.
    my xml structure is like this
    <main_node>
    <node1>
    <name> name1</name1>
    <id>ID</id>
    </node1>
    <node2>
    <name2> name2</name2.
    <id>ID</id>
    </node2.
    </main_node>
    i want to insert node3 in this structure.
    please help, it,s urgent;
    Thanks in Advance

    here is the code if ur using dom..
    Node node4 = doc.createTextNode(name3);
    Element element4=doc.createElement("name3");
    element4.append(node4);
    c one thing that u should take care here is that u have created and is reflected on ly in ur document object and not in xml..for that u have to write some more code like this
    // This method writes a DOM document to a file
    public static void writeXmlFile(Document doc, String filename) {
    try {
    // Prepare the DOM document for writing
    Source source = new DOMSource(doc);
    // Prepare the output file
    File file = new File(filename);
    Result result = new StreamResult(file);
    // Write the DOM document to the file
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.transform(source, result);
    } catch (TransformerConfigurationException e) {
    } catch (TransformerException e) {
    look this code..that will help u
    regards
    [email protected]

  • How to append existed jar file?

    do existed jar file be append again?
    example:
    a.jar // existed jar file
    xyz // forlder that want append to a.jar

    you mean you want to add a directory full of class files to the existing .jar file?
    check the .jar file usage options.
    c:\> jar -helpDiablo

  • Updating an EJB jar file on WL7.0

    Hi
    Iam attempting to update an EBJ jar file without taking down my WL7.0 server.
    When I copy the jar file to the applications directory, I see the server accepting
    the update but when I run my client the update is not visible! Iseem to be still
    accessing the old ejb.
    From my understanding, if the server is running in development mode I should be
    able to copy the jar file with my update directly to the applications directory(
    overwriting old jar file) and be able to access the udated ejb.

    Hello Ron,
    An alternative would be to modify a REDEPLOY file if your application is deployed
    in exploded directory format. However, updating the EJB JAR should also do the
    trick. Try going into the Admin console and explicity redeploying the EJB JAR
    file after copying over the new JAR file. Let us know if any errors appear.
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Ron Turner" <[email protected]> wrote:
    >
    Hi
    Iam attempting to update an EBJ jar file without taking down my WL7.0
    server.
    When I copy the jar file to the applications directory, I see the server
    accepting
    the update but when I run my client the update is not visible! Iseem
    to be still
    accessing the old ejb.
    From my understanding, if the server is running in development mode I
    should be
    able to copy the jar file with my update directly to the applications
    directory(
    overwriting old jar file) and be able to access the udated ejb.

  • Updating an existing xml file using java code

    hi friends,
    I have simple problem, I have an existing xml file and I want to update some of the values in the file.
    can any one send me the java code for that.
    bye.
    -harish

    org.w3c.dom.Document d = parseXmlFile("D:/www/Detailcache/detail.xml", false);
    public static Document parseXmlFile(String filename, boolean validating) {
    try {
    // Create a builder factory
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(validating);
    // Create the builder and parse the file
    Document doc = factory.newDocumentBuilder().parse(new File(filename));
    return doc;
    } catch (Exception e) {
    System.out.println("ERROR-->");e.printStackTrace();
    return null;
    look at .. for more related examples
    http://javaalmanac.com/egs/javax.xml.parsers/BasicDom.html?l=rel

  • Update automatically a JAR file

    He folks!
    Here is what i want to:
    1.
    Develop a little dummy java applet (just for testing), placed in a jar file.
    2.
    That applet should be signed as a trusted applet, so that it can do some more
    stuff on the client and
    3.
    Every time the user starts the applet on his client, the applet should
    check on the server, if there is a newer version, and if so
    update itself automatically, if not just start the jar file on the client machine.
    Does anyone have any suggestions how to do that, or where to get some informations
    about that topic?
    greetings
    Normen

    Every time the user starts the applet on his client,
    the applet should
    check on the server, if there is a newer version, and
    if so
    update itself automatically, if not just start the jar
    file on the client machine.That is already done automatically. If you want to bind the caching to a certain version number, or understand more about applet caching, you should read this single page: http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/applet_caching.html

  • Updating a running JAR file without using JDK

    Hi guys, I have been stuck on this problem for days. I have a program that allows the user to log in and encrypt/decrypt files. This program must be stored on the removable drive and it should work on any operating system without requiring any installation of files. In order to store their login data, I wrote it to a shadow.txt file. My idea was to pack this shadow file into the JAR file so as not to create unnecessary files. I understand that in order to update JAR files, all I need to do is to do
    Runtime.getRuntime().exec("jar uf login.jar shadow.txt");However, here's the problem. I cannot assume that every user PC has JDK installed. As JRE doesn't have jar.exe, that command won't work anymore. Furthermore, the JAR is currently in use. So even if the user has JDK, windows will never allow this command to go through. Anyone has any ideas?

    I had similar requirement, except that, i used a war file.
    Had a client.war file in JBoss deploy directory, and i needed to update client.jnlp file present in it.
    But as jar.exe comes only with jdk, could not use jar -uf command.
    But not sure if it works with other application server too,
    in jboss we can explode the war file, meaning we can create a directory "client.war" in deploy directory and extract your client.war contents to it. Now when server starts, it considers the extracted directory as web archive application.
    This extraction can be done with out using jar.exe. can be done using jarinputstream aswell.
    Once the contents are extracted , the files in it can be modified with out jar.exe.
    For my case it worked as my client.war file is not signed, although the resources inside are signed.

  • How can I update an existing .dot file (created long ago in Word)?

    I send contracts out for my vacation rental with a lot of information and only need part of the info to be specific to each person.
    But now I need to update some of the static info and want to continue using as a .dot. (So saving each updated contract as a .pages file).
    Thanks for any help you can provide!

    Hi Red,
    I'm assuming you no longer have a working version of MS Word.
    .dot is the extension for a Word template file. It can be opened in Pages if you change the extension to .doc.
    You can export the Pages document to a .doc format file, but not to the .dot format. I suspect that changing the extension of the exported .doc to .dot is not sufficient to change the file from a Word Document to a Word Template
    I would suggest that you open the static file into Pages, update the information, then export as a Word (,doc) file AND save it as a Pages file. Use the Pages file as the source file for the information needed to send with each contract, and open the .doc file only when you again need to update the static info.
    Regards,
    Barry

  • When we update an existing pdf file occurence of " /Count"  increases.

    We have one pdf file with 20 pages and when we open this file in editplus to see its content it shows "<</Count 20".
    But when we add new page to it or insert from other pdf file the "<</Count" is shown two times with the values 20 and the added page count, i.e. "<</Count 20", "<</Count 22" (if we added to new pages to it.)
    Please confirm why this happening?

    None of this is unusual or unexpected. Read about incremental updates, and object streams.

  • Adding JAR file to project

    Hi All
    How can i add jar to my project environment.
    Actually what i did was.
    Created one folder called "JavaWork" like d:\JavaWork
    and put the jar file into this folder and wrote a test class which is importing some classes from the jar file.
    how to use jar ? Please someone help me.
    Thanks in advance
    Shan

    `man jar`
    jar(1) jar(1)
    NAME
    jar - Java archive tool
    SYNOPSIS
    jar [ -C ] [ c ] [ f ] [ i ] [ M ] [ m ] [ O ] [ t ] [ u ]
    [ v ]
    [ x file ] [ manifest-file ] destination input-file
    [ input-files ]
    DESCRIPTION
    The jar tool is a Java application that combines multiple
    files into a single JAR archive file. It is also a gen-
    eral-purpose archiving and compression tool, based on ZIP
    and the ZLIB compression format. However, jar was
    designed mainly to facilitate the packaging of Java
    applets or applications into a single archive. When the
    components of an applet or application (.class files,
    images and sounds) are combined into a single archive,
    they can be downloaded by a Java agent (like a browser) in
    a single HTTP transaction, rather than require a new con-
    nection for each piece. This dramatically improves down-
    load time. The jar tool also compresses files, which fur-
    ther improves download time. In addition, it allows indi-
    vidual entries in a file to be signed by the applet author
    so that their origins can be authenticated. The syntax
    for the jar tool is almost identical to the syntax for the
    tar(1) command. A jar archive can be used as a class path
    entry, whether or not it is compressed.
    The three types of input files for the jar tool are:
    o Manifest file (optional)
    o Destination jar file
    o Files to be archived
    Typical usage is:
    example% jar cf myjarfile *.class
    In this example, all the class files in the current direc-
    tory are placed in the file named myjarfile. A manifest
    file is automatically generated by the jar tool and is
    always the first entry in the jar file. By default, it is
    named META-INF/MANIFEST.MF. The manifest file is the
    place where any meta-information about the archive is
    stored. Refer to the Manifest Format in the SEE ALSO sec-
    tion for details about how meta-information is stored in
    the manifest file.
    To use a pre-existing manifest file to create a new jar
    archive, specify the old manifest file with the m option:
    example% jar cmf myManifestFile myJarFile *.class
    When you specify cfm instead of cmf (that is, you invert
    the order of the m and f options), you need to specify the
    name of the jar archive first, followed by the name of the
    manifest file:
    example% jar cfm myJarFile myManifestFile *.class
    The manifest uses RFC822 ASCII format, so it is easy to
    view and process manifest-file contents.
    OPTIONS
    The following options are supported:
    -C Changes directories during execution of the jar com-
    mand. For example:
    example% jar uf foo.jar -C classes *
    c Creates a new or empty archive on the standard out-
    put.
    f The second argument specifies a jar file to process.
    In the case of creation, this refers to the name of
    the jar file to be created (instead of on stdout).
    For table or xtract, the second argument identifies
    the jar file to be listed or extracted.
    i Generates index information for the specified jar
    file and its dependent jar files. For example,
    example% jar i foo.jar
    would generate an INDEX.LIST file in foo.jar which con-
    tains location information for each package in foo.jar and
    all the jar files specified in foo.jar's Class-Path
    attribute.
    M Does not create a manifest file for the entries.
    m Includes manifest information from specified pre-
    existing manifest file. Example use:
    example% jar cmf myManifestFile myJarFile *.class
    You can add special-purpose name-value attribute
    headers to the manifest file that are not contained
    in the default manifest. Examples of such headers
    are those for vendor information, version informa-
    tion, package sealing, and headers to make JAR-bun-
    dled applications executable. See the JAR Files
    trail in the Java Tutorial and the JRE Notes for
    Developers web page for examples of using the m
    option.
    O Stores only, without using ZIP compression.
    t Lists the table of contents from standard output.
    u Updates an existing JAR file by adding files or
    changing the manifest. For example:
    example% jar uf foo.jar foo.class
    adds the file foo.class to the existing JAR file
    foo.jar, and
    example% jar umf foo.jar
    updates foo.jar's manifest with the information in
    manifest.
    v Generates verbose output on stderr.
    x file
    Extracts all files, or just the named files, from
    standard input. If file is omitted, then all files
    are extracted; otherwise, only the specified file or
    files are extracted.
    If any of the files is a directory, then that direc-
    tory is processed recursively.
    EXAMPLES
    To add all of the files in a particular directory to an
    archive:
    example% ls
    0.au 3.au 6.au 9.au at_work.gif
    1.au 4.au 7.au Animator.class monkey.jpg
    e.au 5.au 8.au Wave.class spacemusic.au
    example% jar cvf bundle.jar *
    adding: 0.au
    adding: 1.au
    adding: 2.au
    adding: 3.au
    adding: 4.au
    adding: 5.au
    adding: 6.au
    adding: 7.au
    adding: 8.au
    adding: 9.au
    adding: Animator.class
    adding: Wave.class
    adding: at_work.gif
    adding: monkey.jpg
    adding: spacemusic.au
    example%
    If you already have subdirectories for images, audio
    files, and classes that already exist in an HTML direc-
    tory, use jar to archive each directory to a single jar
    file:
    example% ls
    audio classes images
    example% jar cvf bundle.jar audio classes images
    adding: audio/1.au
    adding: audio/2.au
    adding: audio/3.au
    adding: audio/spacemusic.au
    adding: classes/Animator.class
    adding: classes/Wave.class
    adding: images/monkey.jpg
    adding: images/at_work.gif
    example% ls -l
    total 142
    drwxr-xr-x 2 brown green 512 Aug 1 22:33 audio
    -rw-r--r-- 1 brown green 68677 Aug 1 22:36 bundle.jar
    drwxr-xr-x 2 brown green 512 Aug 1 22:26 classes
    drwxr-xr-x 2 brown green 512 Aug 1 22:25 images
    example%
    To see the entry names in the jar file using the jar tool
    and the t option:
    example% ls
    audio bundle.jar classes images
    example% jar tf bundle.jar
    META-INF/MANIFEST.MF
    audio/1.au
    audio/2.au
    audio/3.au
    audio/spacemusic.au
    classes/Animator.class
    classes/Wave.class
    images/monkey.jpg
    images/at_work.gif
    example%
    To display more information about the files in the
    archive, such as their size and last modified date, use
    the v option:
    example% jar tvf bundle.jar
    145 Thu Aug 01 22:27:00 PDT 1996 META-INF/MANIFEST.MF
    946 Thu Aug 01 22:24:22 PDT 1996 audio/1.au
    1039 Thu Aug 01 22:24:22 PDT 1996 audio/2.au
    993 Thu Aug 01 22:24:22 PDT 1996 audio/3.au
    48072 Thu Aug 01 22:24:23 PDT 1996 audio/spacemusic.au
    16711 Thu Aug 01 22:25:50 PDT 1996 classes/Animator.class
    3368 Thu Aug 01 22:26:02 PDT 1996 classes/Wave.class
    12809 Thu Aug 01 22:24:48 PDT 1996 images/monkey.jpg
    527 Thu Aug 01 22:25:20 PDT 1996 images/at_work.gif
    example%
    If you bundled a stock trade application (applet) into the
    following jar files,
    main.jar buy.jar sell.jar other.jar
    and you specified the Class-Path attribute in main.jar's
    manifest as
    Class-Path: buy.jar sell.jar other.jar
    then you can use the i option to speed up your applica-
    tion's class loading time:
    example$ jar i main.jar
    An INDEX.LIST file is inserted in the META-INF directory
    which will enable the application class loader to download
    the right jar files when it is searching for classes or
    resources.
    SEE ALSO
    keytool(1)
    JAR Files @
    http://java.sun.com/docs/books/tutorial/jar/
    JRE Notes @
    http://java.sun.com/j2se/1.3/runtime.html#exam-
    ple
    JAR Guide @
    http://java.sun.com/j2se/1.3/docs/guide/jar/index.html
    For information on related topics, use the search link @
    http://java.sun.com/
    13 June 2000 jar(1)

  • Error while updating a jar file

    I am trying to update a jar file using teh following command
    jar -uf project.jar fileMy.prop
    however while doing that i get the following error
    java.io.IOException: Error in writing existing jar file
    at sun.tools.jar.Main.run(Main.java:179)
    at sun.tools.jar.Main.main(Main.java:904)

    Perhaps some process (your java program perhaps) is still running that has the file open still? You'll need to shut down the process(es) that have it open. Or you don't have proper rights to the directory/file. Not a java issue.

  • Error in updating jar file in windows

    Hi...
    I am updating a jar file using Runtime.exec() by passing a batch file in it.
    While updating the jar file I am getting error like this:
    java.io.IOException: Error in writing existing jar file
    at sun.tools.jar.Main.run(Main.java:198)
    at sun.tools.jar.Main.main(Main.java:1022)
    The batch file (upgradejar.bat) is like this:
    echo IQuinox NextGen Upgrade Management
    cd shared/upgrade/upgrade/IQfullversion/classes
    jar uf ../../../../../../jars/ng.jar ./qlc/postmaster/PMStartup.class ./qlc/postmaster/wpm/admin/scheduler/others/OthersScheduleServlet.class
    The java code is like this:
    Process p=Runtime.getRuntime.exec( "cmd /C start "+upgradejar.bat);
    if (p.waitFor() != 0) {
    System.err.println("exit value = " +p.exitValue());
    Thanks.

    I am using the jar file in my program. the jar file name is " _ng.jar_ " which is mentioned in the batch file.
    The batch file is here :
    echo IQuinox NextGen Upgrade Management
    cd shared/upgrade/upgrade/IQfullversion/classes
    jar uf ../../../../../../jars/ng.jar ./qlc/postmaster/PMStartup.class ./qlc/postmaster/wpm/admin/scheduler/others/OthersScheduleServlet.class

Maybe you are looking for

  • Facing Problem with HP Laserjet P1007

    I have HP Laserjet P1007, i got driver cd with it. I installed it for the first time. when i turned on my printer, it asked three things, by mistake i selected " Do not ask again for this device ", and now my printer is not working, i have tried ever

  • How do I get my tabs to stay open after I close firefox?

    Every time I open Firefox for the first time after turning on my computer, my tabs are gone. I have my settings set to show my windows and tabs from last time, but that only works if I haven't turned off the computer in-between opening Firefox. I'm n

  • Error Message when trying to access My Network thr...

    I'm getting the following message when I try to access My Network  or PC Health Check via the BT Desktop Help screens. Unexpected error BT Desktop Help encountered a technical issue trying to diagnose the problem on your computer. We advise you to re

  • Power Supply Help

    Hey, I'm building a new computer. The specs are as follows: CASE: Aero Cool Jetmaster Mid Tower ATX MOTHERBOARD: Gigabyte GA-K8NF-9 NVIDIA nForce4 4X (Socket 939) CPU: AMD Athlon 64 3000 (Socket 939) MEMORY: PC3200 400MHz 1 Gig (2x512 Meg) 184pin DDR

  • Need a help to find most suitable AP/Bridge

    Hi, I am searching for wireless connectivity for two office premises which is 50m(line of sight) apart from each other, which should also support at least 30Mbps(this is impartive) traffic. Can I use Cisco Small Business Pro AP 541N AP    to accompli