Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to update application when it is running ??

Posted on 2002-06-04
5
Medium Priority
?
198 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

609 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