470,833 Members | 1,895 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Best Way For a Program to Restart Itself?

My program can, when directed, check a floppy for updates, verify the MD5
sums from another source, then copy the new Java classes to its own
directory tree. Once it does this, I'd like to restart the program so the
changes take effect.

What's the best way to do this?

I figure if I call the program's main class, it will run, but then I'll have
2 instances (the original and the one that's upgraded) running -- plus I'm
not sure if the new class I call will re-load the updated classes from
disk, since it's still run by the same JVM.

I know I can call a program through Runtime, but can I call a program from
Runtime, as if from the command line, and exit the first program, and have
the 2nd continue running?

Thanks!

Hal
Jul 17 '05 #1
2 10911
hi Hal,
im not an expert in java
but if nothing works you can go native way
in c,c++ u can call exec sys call which overloads the given program
over itself without forking so ur parent wll now be ur newly updated
java prog

but in java i think exec will fork first n then load the program in
child (which u dun wan here)

rgrds
amey

Hal Vaughan <ha*@thresholddigital.com> wrote in message news:<re********************@comcast.com>...
My program can, when directed, check a floppy for updates, verify the MD5
sums from another source, then copy the new Java classes to its own
directory tree. Once it does this, I'd like to restart the program so the
changes take effect.

What's the best way to do this?

I figure if I call the program's main class, it will run, but then I'll have
2 instances (the original and the one that's upgraded) running -- plus I'm
not sure if the new class I call will re-load the updated classes from
disk, since it's still run by the same JVM.

I know I can call a program through Runtime, but can I call a program from
Runtime, as if from the command line, and exit the first program, and have
the 2nd continue running?

Thanks!

Hal

Jul 17 '05 #2
Hal Vaughan wrote:
My program can, when directed, check a floppy for updates, verify the
MD5 sums from another source, then copy the new Java classes to its
own directory tree. Once it does this, I'd like to restart the
program so the changes take effect.


What I have successfully done is to have a batch (script) file do the actual
program launch. The java exe then creates a file called NORESTART if the
app should really terminate. After the app terminates, the batch script
checks for the NORESTART file and loops back to launch the app if it doesn't
exist - this will auto restart a crashed app and give me a way to bounce the
app from it's web interface.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by iceman | last post: by
5 posts views Thread by scorpion53061 | last post: by
3 posts views Thread by Matt | last post: by
2 posts views Thread by Tedmond | last post: by
8 posts views Thread by =?Utf-8?B?TWlrZVo=?= | last post: by
1 post views Thread by Sriram Srivatsan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.