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);
}

Similar Messages

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

  • 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

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

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

  • 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

  • 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

  • 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

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

  • 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

  • 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

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

  • Update Jar files

    Hi,
    I'm a beginner in Java. I have a *.jar file and it works. However, the images (icons ) in this complier files I would like to change. I have change the images by keeping the same names. But, when I excuted the program, the old images are loaded. How can I change the imges in a Jar files.
    Thanks,

    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

Maybe you are looking for

  • How do I set one monitor calibration for the whole system and users?

    I'm really angry because when I logged into my first default account, My settings where normal, but I logged into my alt account, the settings where all messed up (NO ONE TOUCHED MY COMPUTER, AND THE ACCOUNT HAS A STRONG PASSWORD) The white balance w

  • HP Officejet 6500 e709n - Solution Center Scan Malfunctio​n

    I've recently purchased a new laptop with Windows 8.1 already installed on it.  I've had my HP 6500 for years and it has worked perfectly - all functions.  When going online to download the drivers to my new laptop, all messages indicate the installa

  • Need help using count over function

    I have the following query Select student_id, OM, TM, TP, count(rownum) over (order by OM desc) PS from (select er.student_id, sum(er.obtained_marks) OM, sum(ds.max_marks) TM, to_char(sum(er.obtained_marks)/sum(ds.max_marks)*100,'990.00') TP from tbl

  • Unable to install apps... help me overcome these obstacles:

    I live in Japan. I got an Original iPad 1. I want to choose an English-only environment (OS, apps, messages), so I set the device language as well as tehe preferred language of my new created Apple ID to "English". Now when I try to install apps, the

  • Why does my Apple Mobile Device Support not uninstall?

    Why does my Apple Mobile Device Support not uninstall from the Control Panel?  It appears that my unsuccessful iTunes install requires that I clean up ALL Apple software,before trying again.