Programatic way of updating jar files

Is there a programmatic way of updating jar files (efficiently)? What I am looking for is an equivalent of jar -u option available in JDK 1.3.
The only way I have right now is to create a new jar file, add the new files into this file and then add the entries from the original.
Spawning jar -u ... is also not a desired option.
Thanks in advance,
Bharat

What am looking for is a programmatic way from my Java program to do so without calling jar -u ...
The method I am looking for is using the java.util.zip/java.util.jar packages to acheive the same result as jar -u...

Similar Messages

  • Updating jar files in ALSB 2.6

    How do we update jar files imported in ALSB projects? Once they have references to them it does not seem feasible to replace them with new version?

    I may not have been clear in my initial post. My questions pertains to jar files that provide POJOs for java callouts. Above link discusses updating project jar with a new version. To create new version of project jar, I think i would first need to update the jar that provides POJOs. Please correct me if there is another way to do it.

  • 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 make the browser reload an updated jar-file?

    Hi there,
    Previosly when running applets using MSIE, all needed to reload an updated jar-file was pressing CTRL+F5
    Currently I've been assigned to re-develop some of my old applets and now I realize that the old CTRL+F5 won't do the trick any more since the old jar file is still in the cache and the new jar file is not loaded.
    I learned the hard way that all I can do is to manually clear the cache of the browser (Tools | Options | Delete files) and restart the browser and after that the new jar file is correctly loaded.
    Cache settings of the browser is set to "Reload on every visit to the page"
    Currently running Win2k, MSIE 6.0 SP1 and MSJVM 3809 but the problem also exists on Win2k, MSIE 6.0 and MSJVM 3186.
    Isn't there any easier way to do this?
    Currently I don't even mind not caching the jar-files at all as long as I don't get my development work trashed by having to restart the browser after every new build...
    Why has the old CTRL+F5 behaviour been changed?
    BR
    /Jonas

    I have been closing IE and reopening it for 7 months now. I don't of any other way to reload an applet.
    Jason

  • 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

  • Detecting updated JAR files

    Hi,
    I have a problem that shows up somewhat infrequently. Once in a while, when I start my offline-allowed application, newer versions the application (e.g. updated JAR files) are not automatically downloaded. If I close the application and restart, the newer JAR files are properly downloaded. Has anyone else seen this problem?
    A perhaps related question I have is how long does web start wait for the head request to come back when it checks for newer JAR files?
    Thanks,
    Joe

    this post may help
    http://forum.java.sun.com/thread.jsp?forum=38&thread=452567

  • Update jar file with modified class files

    hi all,
    I'm developing a jar utility for updating a jar file with modified class files as of now i have reached a point where in i can browse files and set it to required location
    i.e i have developed a swings GUI application using JfileChooser and browse the files ..now my requirement is to update the jar files with modified class file
    GUI looks like below
    ....enter the modified class file ----> d:\c.class
    ....enter the jar file path ---> d:\a.jar
                                                          update button now i have the requirement as
    1> when i click on the update button ,my jar file (a.jar) should get updated with the latest class file (c.class)
    can u help me to achieve this requirement.???
    im stuck with this,,,if u can provide me wit the code for updating jar file with latest class file...it will really be helpful
    if u can help me with the code on click on update button it will be really helpful
    Thanks and expecting a faster response from u all java experts....

    Please find my query in bolds...i have written the partial code now,i need some help now
    hope u guys can help me out...
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.File;
    public class FileExplorer extends JDialog implements ActionListener
         JTextField txtLocation_class;
         JButton btnBrowse_class;
         JLabel label_class;
         JTextField txtLocation_jar;
         JButton btnBrowse_jar;
         JLabel label_jar;
         JButton updatebutton;
         public FileExplorer()
                   setSize(600,300);
                   //for class files
                   label_class = new JLabel("Please select Modified Class File");
                   txtLocation_class= new JTextField(20);
                   btnBrowse_class = new JButton("Browse");
                   btnBrowse_class.addActionListener(this);
                   //for jar files               
                   label_jar = new JLabel(" Please select the Jar file");
                   txtLocation_jar= new JTextField(20);
                   btnBrowse_jar = new JButton("Browse");
                   btnBrowse_jar.addActionListener(this);
                   ActionListener updateListener = new ActionListener(){
                    public void actionPerformed(ActionEvent ae){
                     if(ae.getActionCommand().equalsIgnoreCase("Update")){               
                      System.out.println("ae.getActionCommand() :: "+ae.getActionCommand());
                      System.out.println("Update Button is pressed");               
                    *//Query :how do i access FilePath and FilePath1 here which*
    *                // has been set in public void actionPerformed(ActionEvent ae)*
    *                //method below*
    *                // FilePath  ---??*
    *                // FilePath1  ---??*
    *                // how do i access the above 2 parameters*
    *                //Query :on click of update button i have to pass*
    *                //two parameters FilePath and FilePath1 to*
    *                //perform some functionality. please help me*
    *                //to achieve this..how do i access Filepath and Filepath1*
    *                //here which has been set below.*
                     } // end of if               
                   } // end of actionPerformed
                };// end of ActionListener
                  updatebutton = new JButton("Update");
                  updatebutton.addActionListener(updateListener);
                   //adding to the panel               
                   JPanel pnl = new JPanel();
                   pnl.add(label_class);
                   pnl.add(txtLocation_class);
                   pnl.add(btnBrowse_class);
                   pnl.add(label_jar);
                   pnl.add(txtLocation_jar);
                   pnl.add(btnBrowse_jar);
                  pnl.add(updatebutton);
                   getContentPane().add(pnl);                         
         public void actionPerformed(ActionEvent ae)
              Object obj=ae.getSource();
              if(obj==btnBrowse_class)
                   final JFileChooser fcstudent = new JFileChooser();
                   int rtrnval = fcstudent.showOpenDialog(this);
                   if(rtrnval==JFileChooser.APPROVE_OPTION)
                        try
                             File file=fcstudent.getSelectedFile();                         
                             String path = file.getPath();
                             System.out.println("This is Path:"+path);
                             txtLocation_class.setText(""+path);
                             String FilePath=txtLocation_class.getText();
                             System.out.println("FilePath is ::"+FilePath);                                        
                        catch(Exception ex)               
                             ex.printStackTrace();
              }else if(obj==btnBrowse_jar){
                             final JFileChooser fcstudent = new JFileChooser();
                             int rtrnval = fcstudent.showOpenDialog(this);
                             if(rtrnval==JFileChooser.APPROVE_OPTION)
                                  try
                                       File file=fcstudent.getSelectedFile();                         
                                       String path1 = file.getPath();
                                       System.out.println("This is Path:"+path1);
                                       txtLocation_jar.setText(""+path1);
                                       String FilePath1=txtLocation_jar.getText();
                                       System.out.println("FilePath is ::"+FilePath1);                                        
                                  catch(Exception ex)               
                                       ex.printStackTrace();
         public static void main(String arg[]){
                   FileExplorer Exm= new FileExplorer();
                   Exm.setVisible(true);
    }

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

  • Updating JAR Files

    We're puzzling through a problem with our JAR files and
    unfortunately I'm having no luck finding anything in the forums
    about it. The question is this: If you update the JAR files on your
    Cold Fusion Server, do you have the restart the server in order for
    the updates to take affect? Any help would be greatly appreciated.
    Mike

    Gomba316 wrote:
    > If you update the JAR files on your Cold Fusion Server,
    do you have the restart
    > the server in order for the updates to take affect? Any
    help would be greatly
    > appreciated.
    depends on the JAR. i'd suggest giving javaLoader CFC a look:
    http://www.compoundtheory.com/?action=javaloader.index
    you can make use of java
    JARs/classes way more easily that working via the classpath
    (even if you have
    full control of the classpath, its very useful if you need to
    swap around
    versions of stuff).

  • Dynically update JAR file from a JSP

    i need to put a dynaically created text file from a JSP into a JAR file that will be downloaded by the user. I tried creating a special object from doing this and calling it from the JSP page. When run by itself the object ran file, but when called from the JSP it doesnt work. I put the process of creating the text file in the JSP and it worked however I'm stilll unable to update the JAR file with this newly created text file.
    I created a shell script to update the jar but that still didnt work. I know that this is very insecure too ( i guess there are restrictions on calling system commands).
    So is there a way to put this dynamically create file into a JAR directly from JSP without calling system commands
    Thanks

    Yes, use ZipOutputStream.
    but when called from the JSP it doesnt workSo? Figure out WHY it doesn't work, the fact that you are calling the class from a JSP is not the reason why it is failing, it's a programming mistake inside the class itself. Maybe the class is working but it is creating the jar somewhere where you are not expecting it?

  • 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

  • Is there a way to add jar file in my program

    sorry to botter you, but i really need help for this, i really dont know how to do it. i have my prog taht i want to put in jar file, that cause no problem, but my program isnt fully functionnal because he use a jar file (my driver to acces my database) taht i had mount in forte. but i cant put in in my class file, because i want my jar to be able to run everuwhere on any computer taht have the jre installed. so in resume, i want to add jar file in my program... can i have to add it in my jar file, or decomrpesse it and put the folder like org.postgre.mfileshere... ????? i really dont know
    thx to help me

    ok If I understood, you need to add a third part Jar
    file to your own Jar File App so...
    Yes, you can decompress it in a directory tree and
    merge it with your application (i.e) if you have a jar
    file like this:
    br.com.yourApp.util
    and a third part jar file like this:
    br.com.thirdPart.tools
    br.com.thirdPart.util
    you will have these directory trees:
    br/com/yourApp/util/
    br/com/thirdPart/tools/
    br/com/thirdPart/util/
    then you can marge it in a unique tree:
    br/com/yourApp/util/
    ....../thirdPart/tools/
    ................/util/
    then you can make a new jar file with it...
    .....OR YOU CAN ADD THE PATH where your JDBCDrive is
    placed to the classpath of your application just using
    the -classpath option execution string of you
    application, like this:
    C:\jreHome\bin\java.exe -jar -classpath
    .;C:\someDir\thirdPart.jar yourApp.jar
    That's the better way to do it and then everything
    will work! :-)
    []'s Igor
    Brazil * * * * *k thx, ill give a try, and give you result later. but can you answer me another question, why when i double click on any jar file executable, sometimes javawa start but do nothing, sometimes they start and said no main class find, sometimes dotn start anymore, and sometimes work perfectly...?? is the jdk taht is not good? i use the last one
    or problem with my instalation, or the prog i try to run?
    thx

  • Is there way to debug JAR file,which doesnt has sources.

    Hi
    I have jar file called myjar.jar,which contains only .class files.Assume,I dont have sources for this jar.
    Is there way to debug myjar.jar file??
    However,I can use Djcompiler and get the sources for the jar and use it for debugging.I think,Its not good Idea??
    Thanks in advance.
    Thanks
    kaleem

    Hello,
    Yes - Alt+92 works, but it is too complicated method for most users. As \ is used so often (e.g. login into domain, file and UNC paths) there should be more direct support in keyboard layout.
    Some users are using other Languages (English, Russian) keyboard layout, just to enter that single character.
    Those who know about presence of Microsoft Keyboard Layout Creator load the existing layout and modify it so that VK_OEM_5 key with "\ |" on it in combination with space produce "\" and not "°".
    I would suggest to map "\" to AltGr + "/" key, because it is physically close to VK_OEM_5 and also conceptually idea that AltGr changes meaning from one slash to other is quite logical. That combination is not currently used, so it can be used for that new
    purpose without breaking anything.
    Dainis

  • ...Simplest way to make Jar Files...

    I know there have been numerous questions about jar files and that this has probably been answered before. I am using Forte to develop a program. The program runs fine in Forte, and I used the jar packager to create a jar file. When I double click this file, nothing happens though. I can execute other jar files I have downloaded from the net, but for some reason the ones I create don't work. What is the simplest way to package the classes into a jar file so that I can run my program when I double click it?

    I don't know about double-clicking it to run - that involves making a file association (in Windows) to associate a program with a file type - although I assume you've already done this if you doubleclick others and they run.
    In the case with your own jars it sounds like you need to add a manifest file with the 'Main-class' attribute set to the name of the class that you want to run from the jar.
    eg
    Main-class: YourPackage.YourClass
    The manifest.mf needs to be in a meta-inf dir inside your jar.
    If you open your other jars that do work you will see an example of the manifest.mf file, and the 'Main-class' attribute.
    Also - check in the jdk docs in the tools section - this should tell you all you need to know about the 'jar' tool.
    Hope this helps,
    Kevin Hooke

Maybe you are looking for

  • Updated my ipod to ios5,and now it doesn't play most of my songs.

    I updated my iPod touch 4g to iOS5,and it turned to be much slower than before and the most wired thing is that now it doesn't play most of my songs! Play lists are useless now since if I click one of them and choose some songs,my ipod stops at the s

  • Ibook monitor hook-up

    Many people here seem to need help using an external screen with their ibook, I however need help the other way around! Is it possible to use my ibook G4's 1024x768 screen as a monitor for a computer that's currently monitor-less?

  • Reconciliation Balances

    Hi I am facing pecular problem where my customer balances are not tied to G/L balances means to recon account,why there is difference,i am looking for customer balances in s_alr_87012172 ,debit balance in that report is not tied to reconciliation  ac

  • Cannot stream due to upload being so low with a 50/25 plan

    So I am trying to stream games and I cannot stream due to huge amounts of packets being dropped. I have the upload set to 1.7 in the software and it can't even handle that without dropping a ton of packets. I pay for the 50/25 plan yet I don't get an

  • $tmp package for ABAP proxy

    I am trying to invoke ABAP Client proxy. Can I use $TMP package or do I need to specify a different package? Also if local package is allowed, do I need to set up USE Access?