Update a jar file

hi i have a jar file, which has a fillowing directory. WEB-INF/classes.
I want to add a new file to this directory in the jar file.
How do i do that.

You can use the Runtime class like:
Runtime.getRuntime().exec("jar uf myJar.jar ClassToAdd.class");Unfortunatly you can't programmatically insert a new entry into an existing archive without creating a new one. I think this is a RFE.

Similar Messages

  • 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.

  • How can i add update signed jar file

    I am developing an applet which requires signing to run in a browser.
    I am developing supporting classes. But these class files have to be added
    to the jar. Isnt it??
    But to test the applet i need to load it in the browser each time i modify the class files. So the jar file need to be updated every time. But an
    IOError
    is being displayed when i try to update the signed jar file.
    How can i update signed jar file?? Or is there any othe way to test the signed applet during development??

    How can i update signed jar file?You can't, the signature is there to make sure the content of the jare hasn't been messed
    with.
    Either recreate the jar and re sign it or set up a policy during testing.

  • Problem in updating a jar file

    Hi ...
    Anyone help me for updating a jar file in windows.
    I am updating a jar file Using Runtime.exec() method.. But it shows an 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)
    I am using jdk1.6 and ant tool for build.

    Stick to your old thread please.
    [http://forums.sun.com/thread.jspa?threadID=5320704&messageID=10371347#10371347]
    I'll delete this one soon.

  • Updating a jar file

    I am using the following ant file in eclipse to build jar files when I ask the project to be built
    <project name="atg" default="create-jar">
        <target name="create-jar">
            <jar jarfile="${jarlocation}/classesDAS.jar">
                <fileset dir="WebContent/WEB-INF/classes" includes="**/*.class"/>
                <fileset dir="WebContent/WEB-INF/classes" includes="**/*.properties"/>
            </jar>
        </target>
    </project>Is there a possibility that I modify this file to rather update jar files rather than creating new ones??????

    Something did occur to me.... If you use update, then
    presumably Ant works by taking newer/modified files
    that have timestamps after the modified time of the
    Jar... IF you were to move things around to other
    packages, or directories for non-class files, in your
    development process, then you could end up with
    duplicate items in different locations in the Jar,
    which could lead to hard to find bugs later if you
    forgot to update the paths elsewhere, or end up
    updating the wrong files. So IMO, it's safer all
    around to just let it create a new Jar so that it's
    always clean.Thanx all of you for taking out some time to advise me. I really appreciate that. The reason I am more interested in update is because of the situation I am trapped in. We are using a third party API to talk to the oracle database. Though I personally would prefer using JDBC myself but here I have no choice as its a decision made at much higher levels. Now there are advantages with this API that it maintains a cache and you donot have to do SQL queries all the time, but I was having problem since a few days as it would not always provide me with the right results. Since I was the one assigned to look into it I decided to decompile some of the classes and put them into a project in WSAD/Eclipse. Now there are thousands of classes in this jar file and I donot want to decompile all of them and add them to the project what I was wondering was to add this ant script to the project file add some debug statements and hopfully it would change only the files I want it to rather than creating a new jar file with just 10 files rather than all of them. This was the background of my question. So what do u suggest now. I donot want to do jar -uvf after moving class files everytime I compile thats why I wanted to use ant.

  • Updating a JAR file in a shared folder

    Hi,
    I have a JDK 6 Swing app running in a Windows Terminal Server. All users share the same JAR file. I start it using a bat file something like this:
    start /b c:\progra~1\java\jre\bin\javaw -jar gestor.jarAll works fine when users share the same JAR.
    However, when I try to update JAR file to a new version, "sometimes" (not always) when there are some users with JAR file running by JVM, it occurs some strange behaviours with the app, errors like JVM would become lost/crazy with a JAR in RAM and other JAR in disk.
    Is not this a good approach to update the app? Is it better to disconnect all users before update app?

    I don't know what SUNs policy on this is. But if I were you, I'd create a link (shortcut in windows) to the JAR file, and when you have a new version, put it in the same folder as the previous release, but with a different name, and update the link/shortcut. Users should only know about the link/shortcut. Depending on the behaviour of the windows shortcut, users using the JAR file will still use the old file as you update the link to point to the new file. Feasible?

  • JNLP file version based update like Jar files version?

    Dear All,
    We are using the JWS from the past one year. Its working fine except one or two issues.
    Here i am explaining one of those issues:
    When user double clicks the icon on his desktop, first the JWS checks for updates. If updates found it will download the updates and starts the application.
    JWS doing the updates checking as:
    First its checking the time stamps of the client and server JNLP files. If server JNLP file time stamp is grater than client JNLP file time stamp, then its checks for each and every jar file update.
    For Jar files update we are using the version based. Our JNLP file is as shown below:
    <jnlp spec="1.0" codebase="$$codebase" href="LaunchMedplexus.jnlp">
    <information>
    <title>CBST</title>
    <vendor>CBST</vendor>
    <description kind="short">CBST</description>
    <icon href="../../../../images/image1.gif" kind="splash"/>
    <icon href="../../../../images/image1.jpg"/>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.4" initial-heap-size="48m" max-heap-size="256m"/>
    <jar href="../../../../JARS/AppJars/POMS/admin/admin.jar"      version="7.7.0.0" />
    <jar href="../../../../JARS/AppJars/POMS/billing/bil_adj.jar"      version="7.7.0.0" />
    </resources>
    <application-desc main-class="com.test.security.Login">      
    </application-desc>
    </jnlp>
    we are facing the problems because JWS updates checking is based on the JNLP file time stamp.
    is there is any way in JWS to check the updates based on JNLP file version instead of timestamp (like jars version based)?
    Our Environment is :
    JRE : 1.4.2_10
    OS : Windows 2000/XP
    thanks in adavance
    Krishna Mohan.

    Dear Andy,
    Thank You for your reply.
    perhaps you can use a simple jnlp file that referre to almost all of the application using a versioned jnlp component extension.can you explain this line little more elaborately.
    thanks in advance
    km

  • 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

  • Error  While Opening an Updated JAR file

    Frnds,
    I have some problem with a JAR file update. Seek ur help in this regard.Here goes my problem.
    I need to update a jar file ( need to replace a single .class file with a new one ). I updated the JAR file using ' jar uf ' command and it was successfull.. I removed the old JAR file and replaced it with the updated JAR file. But when i tried to invoke the JAR application using Java we start iam unable to open the applicaiton. But when i replace this upadted JAR file with the old JAR file ( using the backup) the application loads correctly.
    The application is hposted in Apcahe web server. Is a server restart required after deploying the updated JAR file or is this porblem due to some other reasons.
    Thanks in advance.
    Regards,
    Bala.

    It appears that the New Report .vi only accepts the .xlt template format and not .xltx as one would commonly expect. I am currently working to determine for sure that this is the case, but it does run (mostly) properly on my end if you make that change.
    When I say mostly, I mean there are a couple other minor issues with your code. First the first frame of your sequence structure is really accomplishing anything. If your intent is to open a reference to the excel template, there is no need because the New Report .vi does it automatically.
    Second, you will need a file path of some sort wired in to your Save Report to File .vi or else you will get a different error message after fixing the .xlt issue. I am currently researching whether this should be marked as a required terminal instead of recommended so that it not being wired would result in a broken run arrow rather than an error.
    Let me know if these suggestions resolve your issue, or if I can provide further input on what you are doing in your first frame. I will touch base again once I determine whether these are expected behaviors or bugs.
    Christopher S. | Applications Engineer
    Certified LabVIEW Developer
    "If in doubt... flat out." - Colin McRae

  • JAR File Will NOT Update on WebStart!

    I want an updated jar application to run on WebStart, but it always runs the original jar file I put on the server. (The update of the jar file works fine by itself.) I have updated the .jar file as well as the .jnlp file. I have tried deleting the cache in Webstart. I have also fully reloaded WebStart, and the .jar files when nothing else worked. I even totally renamed the .jar and .jnlp files, and it still runs the original file. Everything else works smoothly.
    Any suggestions?

    If you want your application to always check for a new version, you should use the JNLP API, i think the DownloadService(http://java.sun.com/products/javawebstart/docs/javadoc/javax/jnlp/DownloadService.html) interface will do the job. Here�s an example:
    import javax.jnlp.*;
        DownloadService ds;
        try {
            ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
        } catch (UnavailableServiceException e) {
            ds = null;
        if (ds != null) {
            try {
                URL url =
                        new URL("http://java.sun.com/products/javawebstart/lib/YOURAPP.jar");
                if ( ! YourApp.isLastVersion() ) { // some method to check versions on the server....
                    ds.removeResource(url, "1.0");
                    // reload the resource into the cache
                   DownloadServiceListener dsl = ds.getDefaultProgressWindow();
                   ds.loadResource(url, "1.0", dsl);
            } catch (Exception e) {
                e.printStackTrace();
        }

  • Incremental update jar files

    Hi,
    I want to update a jar file but everything I do ends in
    "Missing version field in response from server when accessing resource".
    Do I need a version.xml? If I need this how should it looks like? Could someone write an example for that mission?
    Regards,
    Patrick
    Thats my project:
    /myapp/myapp.html
    /myapp/myapplication.jar
    /myapp/myapplication.jnlp
    /myapp/myapplication.jpg
    /myapp/meta-inf/Manifest.mf
    /myapp/web-inf/web.xml
    /myapp/web-inf/lib/jaxp.jar
    /myapp/web-inf/lib/jnlp-servlet.jar
    /myapp/web-inf/lib/parser.jar
    web.xml:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
    <web-app>
         <servlet>
                   <servlet-name>JnlpDownloadServlet</servlet-name>
                   <servlet-class>com.sun.javaws.servlet.JnlpDownloadServlet</servlet-class>
              <init-param>
                   <param-name>loglevel</param-name>
                   <param-value>DEBUG</param-value>
              </init-param>
              <init-param>
                   <param-name>logPath</param-name>
                   <param-value>/logs/jnlpdownloadservlet.log</param-value>
              </init-param>
              <mime-mapping>
                   <extension>
                        jnlp
                   </extension>
                   <mime-type>
                        application/x-java-jnlp-file               
                   </mime-type>
              </mime-mapping>
              <mime-mapping>
                   <extension>
                        jardiff
                   </extension>
                   <mime-type>
                        application/x-java-archive-diff               
                   </mime-type>
              </mime-mapping>
         </servlet>
    </web-app>
    jnlp:
    <jnlp spec="1.0+" codebase="http://asgard/myapp" href="myapplication.jnlp" version="2.0">
    <information>
    <title>MyApplication</title>
    <vendor>Patrick Scholze</vendor>
    <homepage href="../myapp.html" />
    <description kind="">MyApplication</description>
    <description kind="short">myapp</description>
    <icon kind="default" href="myapplication.jpg" />
    </information>
    <resources>
    <j2se version="1.2+" />
    <jar href="myapplication.jar" main="true" download="eager" version="2.0"/>
    </resources>
    <application-desc main-class="Start">
    </application-desc>
    <security>
    <all-permissions />
    </security>
    </jnlp>

    Now there are no error messages but JWS downloads the
    complete jar file.If you specify "eager", Web Start is told to load that jar immeadiately.
    What exactly do you have in mind with that jar?
    Lazy download (thus at a latter time), or the download of a specific version of the jar or differential download?
    Regards,
    Marc

  • Updated JAR files in j2ee/home/lib

    We are developing and deploying j2ee applications to a 9.0.2.3 9iAS server. We have a framework.jar file that we have a number of applications in two OC4J instances (home and portal) that need to use this jar file. As a result, we place the jar file in the j2ee/home/lib directory since this could be seen by all applications. My question comes in when we try and update this jar file. We seem to experience problems when moving a new framework.jar file into the directory. We mainly notice this issue in our EM Website. We begin to get the following error in the EM Website after we move an updated jar file into the directory:
    Servlet error: Renderer failed: java.lang.InternalError: jzentry == 0
    I've seen this error before and it seems to link back to a problem with jar files. If I remove the new jar file the error disappears. We are eventually able to get the jar file in, but only after restarting the whole mid-tier. Is this normal? Should we have to restart the server everytime we update the jar file? If so, what would be the best way to implement the new jar files? Stop mid-tier, move new file in and restart??
    Would you recommend a different location for this jar file?? Our biggest concern is that we only want to deploy this jar file one time and have all applications that need it find it. Thanks in advance for any input you might have.
    Beth

    Libraries loaded from the j2ee/home/lib directory are opened and loaded at the J2EE container level. So they are accessed from the very start of the server, to the point where it is stopped.
    Therefore if you modify a class library which has already been loaded, you may run into file locking related issues (which will be OS dependent, Windows for example probably won't even let you overwrite the file) so that is what you are likely to be seeing.
    JAR files loaded at the J2EE container level aren't really suitable for dynamic updating -- the classes can be referenced in a multitude of other classloaders.
    As you have seen, replacing a J2EE container level class file, then a restart will be required along the lines of what you have written.
    Stop mid-tier, move new file in and restart?? cheers
    -steve-

  • How to Update Jar Files

    Can u tell me how to update an JAR file .
    I have a jar file ,I would like to add a class in that jar.
    I am able to add it but it goes
    into the root folder where as i want it go in one of the sub folder.
    Eg
    TEST.JAR
    The structure is
    Server\a.class
    Server\folder1\b.class
    Server\folder2\c.class
    Now when i add the class it goes to
    Server\a.class
    Server\folder1\b.class
    Server\folder2\c.class
    my.class
    where as i want it to go in
    Server\folder1\my.class

    Show the code you use to add it to the JAR, and we will attempt to fix it. Don't forget to put it around [code]  tags

  • Lazy downloading broken for updated jar-files?

    Hello,
    Using webstart-6.0 + jar-index + download="lazy" works great - jar files are downloaded on demand when they are really needed.
    However when updating all jar-files, the files that have been downloaded lazily and cached before are downloaded again before the application can be launched, not only on demand.
    Is this the intended behaviour, and is there any way to let webstart lazily download updates, just when the jar-files are needed?
    Thank you in advance, lg Clemens

    Libraries loaded from the j2ee/home/lib directory are opened and loaded at the J2EE container level. So they are accessed from the very start of the server, to the point where it is stopped.
    Therefore if you modify a class library which has already been loaded, you may run into file locking related issues (which will be OS dependent, Windows for example probably won't even let you overwrite the file) so that is what you are likely to be seeing.
    JAR files loaded at the J2EE container level aren't really suitable for dynamic updating -- the classes can be referenced in a multitude of other classloaders.
    As you have seen, replacing a J2EE container level class file, then a restart will be required along the lines of what you have written.
    Stop mid-tier, move new file in and restart?? cheers
    -steve-

  • Update jar file by removing existing files

    hello,
    is there a way to update a jar file by removing indicated files within the jar file ?
    I saw that it is possible to update a jar file by adding files to it: jar uf jar-file input-file(s)
    I want to avoid:
    1)extracting the file
    2) remove indicated files
    3) compress again.
    thank you !

    >
    I want to avoid:
    1)extracting the file
    2) remove indicated files
    3) compress again.>If you don't want to do it, make Ant do it, and be happy (get on with your life, do fun things etc.).

Maybe you are looking for

  • Matshita UJ-816 Superdrive: Blank CD-R / DVD-R fail to mount; Error Code 13

    Greetings all, *deep breath* This will be a long question, but I want to be thorough and informative. Sorry. My machine is a 1Ghz 12" PB with a Matshita DVD-R UJ-816 DXJ3 Superdrive. It's basically worked fine for reading & burning all common brands

  • External hard drive won't appear

    I bought a 250GB Formac external hard drive a few years ago and have used it on and off to back up my old G4 powerbook. I purchased my MacBook in March this year and have previously connected it to the Formac drive without any problems. A couple of w

  • Flow of the marketing process

    Hello everyone, I'm new in this community. I would ask if anyone can explain how the flow of the process of marketing management in Oracle Siebel. For example to create a new segment, I add the attributes in the side of presentation of Oracle Siebel

  • Can't load previously installed Acrobat 9 Pro after my CS6 trial expired.

    Can't load previously installed Acrobat 9 Pro after my CS6 trial expired. Keeps asking to buy the trial version or license the software (in reference to the CS6 trial, even though I'm loading my own Acrobat 9 Pro from my CS4 Creative Suite I purchase

  • How to read in a text file of race lap times....

    How do i read in a text file containing lap times from a race for one driver? I have the times down 1 column and look like this. I then want to add the times up to get a total race time. I have been looking at the Calendar class and the simpleDateFun