Solved

How to update application when it is running ??

Posted on 2002-06-04
5
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 7054990
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
ID: 7055575
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
ID: 7056578
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
ID: 7070565
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
ID: 8833971
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

734 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