Im wondering how I might be able to implement an "auto update" type of
procedure. I have a server program, all packaged up in a jar file, running
on a corporate server. That server has firewall access to another server,
out on the internet, wherein I can put a new, updated version of that jar
file, if necessary.
What I'd like to figure out is if there is a means whereby I can 1. Stop the
server program from running so that 2. It can download the new incarnation
of itself and 3. Restart itself.
Anyone have any ideas on such a mechanism? Thanks, Ike
Andrey Kuznetsov - 09 Apr 2006 06:19 GMT
> Im wondering how I might be able to implement an "auto update" type of
> procedure. I have a server program, all packaged up in a jar file, running
[quoted text clipped - 8 lines]
>
> Anyone have any ideas on such a mechanism? Thanks, Ike
hmm, something like this (didn't tried it yet):
//from main programm (on windows, I am sure on Linux you can find something
similar to Start):
Runtime#exec("start java <myUpdateProgramm> -Dpath=<mainProgrammPath>");
System.exit(0);
//update programm
readNewVersion();
int errorCount = 0;
while(true) {
try {
//try to save update
saveUpdate(getUpdatePath());
System.exit(0);
}
catch(UpdateFailedException ex) {
//main programm still running?
if(errorCount++ > MAX_ERROR_COUNT) {
//something goes wrong
System.exit(0);
}
Thread.sleep(5000);
}
}
Andrey

Signature
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
Ike - 09 Apr 2006 18:05 GMT
Thanks Andrey -- that's damn near perfect, exactly what I was trying to do!
Thank you, Ike