By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,557 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,557 IT Pros & Developers. It's quick & easy.

Best Way For a Program to Restart Itself?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.