Solved

How to update application when it is running ??

Posted on 2002-06-04
5
169 Views
Last Modified: 2010-03-31
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");
oldf.renameTo(newf);
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
Gary
0
Comment
Question by:garyshi
5 Comments
 
LVL 16

Expert Comment

by:imladris
Comment Utility
How about running it from a batch file. The batch file could contain a loop. In pseudo code something like:

Forever
   Run Java application
   Upgrade application


So that when you exit the application it gets updated, then the application is run again.
0
 
LVL 7

Expert Comment

by:tomboshell
Comment Utility
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.
0
 
LVL 3

Expert Comment

by:oraelbis
Comment Utility
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.
0
 
LVL 9

Accepted Solution

by:
doronb earned 100 total points
Comment Utility
Hi,


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

Doron
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now