• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

How to update application when it is running ??

I want to update my pure java application when it is runing. I have a button called "update". When this button is clicked, it will download new version to temp folder for this application from server and update it. In detail, some of files for this application will be moved to backup folder and new files will be moved from temp folder to destination folder. I use below java classes to move files:
File oldf=new File("c:/../oldFile");
File newf=new File("c:/../newFile");
My problem: When oldFile is not refered/referenced by application, this moving will be successful. If oldFile is refered/referenced by application, this moving will fail. How to handle this problem ??

When I plan to use System.exit(o), then, update application, when System.exit() is called , it shutdown everything. I cann't do anything. I cann't do update. How can I shutdown my application without using System.exit() ? so I can do update after shuting down app. Thanks for help
1 Solution
How about running it from a batch file. The batch file could contain a loop. In pseudo code something like:

   Run Java application
   Upgrade application

So that when you exit the application it gets updated, then the application is run again.
What about a 'stand-in' application?  Another application that can start & stop your original app.  It would do the updating and could be in the same path. It doesn't even have to be a large program.
I think, that you must create some Addin interface,
implement it in your plugable classes an dinamicaly load classes using your own extension API. Check your development tool for extension mechanism. May be you create you API something like it. For example in Oracle Java Developer realised the Addin interface for adding functionality to the Oracle Tools IDE.

I'm working on something along the same lines. I have an application that can activate plugins. These
plugins are simple Java classes implementing a common Plugin interface.

When I want to update a plugin, the application receives a JAR file containing the new plugin code.
The application then attempts to close all live instances of the old plugin and then remove its JAR
file. Once the old JAR file is removed, I can replace it with the new JAR and load the new plugin.

In order to accomplish this, my plugins are loaded dynamically by my own ClassLoader. This enables me
to "deactivate-and-replace" live code. Keep in mind though that any references to the old plugin must
be null and void before swapping the code.

Hope this helps

No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to doronb

Please leave any comments here within the
next seven days.


Cleanup Volunteer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now