How to update files in jar?

Is there any way that I can update a file stored in a jar?

If I create a temporary file and then replace the
original one, would the contents of META-INF in the
original jar (which I want to keep) be replaced too?Yes, you have to rebundle the contents of the META-INF. I didn't knew it still existed, but here is a link to MoaJar:
http://www.opengroup.org/moajar/tools.zip
The API handles deleting files, I haven't inspected the source yet, but I think it's working by replacing the original JAR file.
Greets.

Similar Messages

  • How to update file in Jar using API

    Hi,
    I have a jar file (actually a war file), and I need to update the properties in one of the files before I deploy it.
    I have been able to open it, get the correct JarEntry, load the properties, update the properties, but am struggling to figure out how to save it back to the Jar file?
    Any ideas?
    cheers,
    David

    So why isn't your build process just creating thecorrect contents of that properties file
    before including it in the war it builds, in thefirst place?
    Because we deploy it in many customers. They will
    obviously have different ip addresses eg for the
    database machine.
    Therefore we have certain properties that are
    customer-specific we need to update in the war before
    we deploy it.
    cheers,
    DavidI wasn't implying that your build process is only run one time. The build process can be run each time you build for each deployment. So do you mean you only want to deliver one generic WAR to each customer, and you want this change of properties to happen on the customer side somehow? What code are you going to run on that side to change it - not code in your web app because at that point it's too late - you've already loaded the web app and its files, which this/these property files are a part of. Sounds like you need a "build process" to bundle up the app for each unique target.
    Alternatively you could investigate adding or altering the manifest file in the WAR (or EAR) file to reference an additional standalone, or loose, directory (outside the WAR/EAR structure) and put your property files there. Then that directory would become part of your app's classpath just like it were in your WAR/EAR, and you could update that file independently.

  • How to list files from .jar file in applet?

    I have created applet and export all files to .jar file.
    I use File.list() method in applet to list files from one directory and that works ok but if I try to do that from web browser it sends exception AccessDenied meaning that File.list() isn't allowed in browser.
    I know what's the problem but I don't know how to solve it.
    What I want is to read from directory list of files.
    Help anyone?

    I will post here my code so that can be seen what I want to do:
    import java.awt.BorderLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URLClassLoader;
    import java.nio.charset.Charset;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JTextPane;
    public class test extends JApplet {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JTextPane jTextPane = null;
          * This is the xxx default constructor
         public test() {
              super();
          * This method initializes this
          * @return void
         public void init() {
              this.setSize(449, 317);
              this.setContentPane(getJContentPane());
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.add(getJTextPane(), BorderLayout.CENTER);
              return jContentPane;
          * This method initializes jTextPane     
          * @return javax.swing.JTextPane     
         private JTextPane getJTextPane() {
              if (jTextPane == null) {
                   jTextPane = new JTextPane();
              return jTextPane;
         public void start(){
              File fileDir= new File("somedirectory");
              String strFiles[]= fileDir.list();
              String a="";
              for(int i =0;i<strFiles.length;i++){
                   a=a+strFiles;
              this.jTextPane.setText(a);
    Method init() is irelevant, it just adds JTextPane in applet.
    Method start() is relevant, it runs normaly when started from Eclipse but from browser it sends exception AccessDenied.

  • How to use files in Jar file

    Hi,
    I have one program which displays images on main form.
    But when I package all these classes and image files it shows file not found.
    I want it should read the image files which are in the same jar file.
    How can I use the files which are packaged in a Jar file?

    Here's some sample code I stole from another website.
    public void readTextFromJar(String s) {
    String thisLine;
    try {
    InputStream is = getClass().getResourceAsStream(s);
    BufferedReader br = new BufferedReader
    (new InputStreamReader(is));
    while ((thisLine = br.readLine()) != null) { 
    System.out.println(thisLine);
    catch (Exception e) {
    e.printStackTrace();
    }

  • How to update file name of SharePoint form library?

    HI All,
    I have a Infopath form library and submitted as "Form-1". Once update and submit, the same form name should change as "Form-1.1" with out duplicating. How to achieve this, thanks in advance!

    Hi Sam, check out the following link. It will get you started. You'll have to customize the way the file is named differently than shown, but you'll get the idea:
    http://claytoncobb.com/2009/06/20/auto-generating-filenames-for-infopath-forms/
    cameron rautmann

  • How to read file in JAR file (the one containing applet class)

    my applet needs to read a file (font file) that will be bundled in the jar file. how do i read that file?
    i tried using
    URL u = new URL("file:///myfont.ttf");
    u.openStream();i got AccessControlException. is there anyway for the applet to load file in the JAR file? i see applet can load image in the jar file so figured that it should be able to do so with some other type of file
    thanks

    The reason you're getting access violation is the way you code your URL -- it's pointing to a file on the user's local disk. If my.ttf is in the jar, try:
          URL url=myApplet.class.getClassLoader().getResource("myfont.ttf");Where myApplet is the name of your applet and the font file is assumedly kept in the same directory level in the jar file as the class file for your applet.
    ;o)
    V.V.

  • How to delete files from JAR ?

    Hi,
    Is there any way to delete a file from the jar ?
    I just want to delete some class files from the jar without deleting and again uploading the JAR.
    Thanks & Regards,
    Atur Shah

    You can automate this using the following example:
    echo Remove xalan from runtime
    echo .
    echo JAVA_HOME: %JAVA_HOME%
    echo .
    rmdir /s /q %TEMP%\rt
    mkdir %TEMP%\rt
    pushd %TEMP%\rt
    %JAVA_HOME%\bin\jar -xf %JAVA_HOME%\jre\lib\rt.jar
    rmdir /s /q org\apache\xml
    rmdir /s /q org\apache\xalan
    rmdir /s /q org\apache\xpath
    %JAVA_HOME%\bin\jar -cf ..\rt.jar *
    copy %JAVA_HOME%\jre\lib\rt.jar %JAVA_HOME%\jre\lib\rt.jar.old
    copy ..\rt.jar %JAVA_HOME%\jre\lib\
    popd

  • How to get files in jar

    hi, i built a small application to learn,now i am trying to make it a jar file with NetBeans 5.0. but the jar file throws IO exceptions. it says it cannot find the file inside the application.
    lets say, i am trying to read from "src/others/Default.properties", when i run with NetBeans,it find the file,but when i build the jar file and run it. it cannot find "src/others/Default.properties"
    what am i supposed to do?

    This is the solution(below) for my question. I think i couldnt ask it properly because some people give very strange answers.
    I ll try to be more clear next time and thanks for all your responses.
    URL url = this.getClass().getResource("/hello.jpg");
    or you can get an InputStream to read it like this:
    InputStream is = this.getClass().getResourceAsStream("/app.properties");

  • How to update files

    I started using my new macbook pro a few days ago. I downloaded music, photos, etc. and then I found the two disks in the "Everything Else" folder. I downloaded them. When downloading the first one, i told it to put my files in a folder named "Previous Systems" so I could just download them when the disks had done what they were supposed to do. I tried doing that, but it won't let me open any of the files. My iPod has music on it, but iTunes won't let me put it back on. Can anyone help me?

    I'm not sure if this is something that you have created in-house or
    not, but generally the CAB file is responsible for shutting down the
    application.. So what you would do is create your CAB file so that it has a
    setup.dll that runs before the file copy and shuts down the application, prior
    to copying in the app.
    I hope this helps.
    Dave Kegel
    >>> <[email protected]> 5/30/03 2:22:32 PM >>>
    Dave,
    Your are correct. It is a PPC and we are distributing a CAB file.
    JC Kemble
    Southwest Airlines
    > Hello,
    >
    > Is this Pocket PC or Palm you're distributing to? Sounds like it's
    PPC,
    =
    > and you're distributing a CAB file?
    >
    > Dave Kegel
    > Novell, Inc.
    >
    > >>> <[email protected]> 5/30/03 12:08:32 PM >>>
    >
    > I'm using ZfH 5.1 and everything has been working great until now.
    We=20
    > have an application that is always running on the handheld that
    needs =
    > to=20
    > be updated. When the update starts a window will pop up saying a
    file =
    > is=20
    > in use. Is there a way to force it to upgrade the application or
    stop =
    > the=20
    > applcation without any user intervention?
    >
    >

  • How to updates file when template is changed

    Hello fellow dw users..
    Is there somebody whocan help me. My problem is that I
    created my website by using a template,
    now I need to chagne the color and some background images on
    my template after updating the template
    how would I let all my web pages be affected and follow and
    use the updated the template instead of the old one? hope you can
    help me . thanks a lot!!

    When you save the changed template, all changes to
    NON-editable regions are
    automatically propagated to all local child pages of that
    template. Is that
    not happening for you?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "teamse1" <[email protected]> wrote in
    message
    news:eb7ljd$12b$[email protected]..
    > Hello fellow dw users..
    >
    > Is there somebody whocan help me. My problem is that I
    created my website
    > by
    > using a template,
    > now I need to chagne the color and some background
    images on my template
    > after
    > updating the template
    > how would I let all my web pages be affected and follow
    and use the
    > updated
    > the template instead of the old one? hope you can help
    me . thanks a lot!!
    >

  • 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

  • How to update session.xml file

    any body have an idea about how to update the session.xml file using Toplink workbench Editor.
    I have an Jar file which contains the session.xml file , so i am trying to update the session.xml file with me database details.

    any body have an idea about how to update the
    session.xml file using Toplink workbench Editor.
    For 10.1.3, see "Sessions Configurations and the sessions.xml File" in the TopLink Developer's Guide: http://www.oracle.com/technology/products/ias/toplink/doc/10131/main/_html/sesun002.htm#CACIGEBC
    For 10.1.2, see "OracleAS TopLink Sessions Editor" in the TopLink Mapping Workbench Guide: http://download.oracle.com/docs/cd/B14099_16/web.1012/b15900/tscedit.htm

  • How to update JAR through URL

    Hello,
    I have implemented a standalone JAR file for windows, that runs in a system tray for our users to use. The application is using URL class to connect to our server and feed information. Trouble is that from time to time it may be necessary to update files packed in this JAR to give it other features. Instead of asking our users to download the JAR, I would like to have an option to update this JAR with a new JAR from the server, consequently using URL class.
    Could somebody please give me an idea on how to "download" a new JAR version and "replace" it with the existing one? So essential this should work as your typical "check for updates" feature. Any ideas on this matter will greatly be appreciated.
    Thank you,
    Victor.

    Java Web Start

  • 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

  • How to update link and import data of relocated incx file into inca file?

    Subject : <br />how to update link and import data of relocated incx file into inca file.?<br />The incx file was originally part of the inca file and it has been relocated.<br />-------------------<br /><br />Hello All,<br /><br />I am working on InDesignCS2 and InCopyCS2.<br />From indesign I am creating an assignment file as well as incopy files.(.inca and .incx file created through exporing).<br />Now indesign hardcodes the path of the incx files in inca file.So if I put the incx files in different folder then after opening the inca file in InCopy , I am getting the alert stating that " The document doesn't consists of any incopy story" and all the linked story will flag a red question mark icon.<br />So I tried to recreate and update the links.<br />Below is my code for that<br /><br />//code start*****************************<br />//creating kDataLinkHelperBoss<br />InterfacePtr<IDataLinkHelper> dataLinkHelper(static_cast<IDataLinkHelper*><br />(CreateObject2<IDataLinkHelper>(kDataLinkHelperBoss)));<br /><br />/**<br />The newFileToBeLinkedPath is the path of the incx file which is relocated.<br />And it was previously part of the inca file.<br />eg. earlier it was c:\\test.incx now it is d:\\test.incx<br />*/<br />IDFile newIDFileToBeLinked(newFileToBeLinkedPath);<br /><br />//create the datelink<br />IDataLink * dlk = dataLinkHelper->CreateDataLink(newIDFileToBeLinked);<br /><br />NameInfo name;<br />PMString type;<br />uint32 fileType;<br /><br />dlk->GetNameInfo(&name,&type,&fileType);<br /><br />//relink the story     <br />InterfacePtr<ICommand> relinkCmd(CmdUtils::CreateCommand(kRestoreLinkCmdBoss)); <br /><br />InterfacePtr<IRestoreLinkCmdData> relinkCmdData(relinkCmd, IID_IRESTORELINKCMDDATA);<br /><br />relinkCmdData->Set(database, dataLinkUID, &name, &type, fileType, IDataLink::kLinkNormal); <br /><br />ErrorCode err = CmdUtils::ProcessCommand(relinkCmd); <br /><br />//Update the link now                         <br />InterfacePtr<IUpdateLink> updateLink(dataLinkHelper, UseDefaultIID()); <br />UID newLinkUID; <br />err = updateLink->DoUpdateLink(dl, &newLinkUID, kFullUI); <br />//code end*********************<br /><br />I am able to create the proper link.But the data which is there in the incx file is not getting imported in the linked story.But if I modify the newlinked story from the inca file,the incx file will be getting update.(all its previous content will be deleted.)<br />I tried using <br />Utils<IInCopyWorkflow>()->ImportStory()<br /> ,But its import the incx file in xml format.<br /><br />What is the solution of this then?<br />Kindly help me as I am terribly stuck since last few days.<br /><br />Thanks and Regards,<br />Yopangjo

    >
    I can say that anybody with
    no experience could easily do an export/import in
    MSSQLServer 2000.
    Anybody with no experience should not mess up my Oracle Databases !

Maybe you are looking for