473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 11090
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: S.Sigal | last post by:
Hello: Always wanted to do this -- but never knew how... The goal is to write software that goes out to clients -- but I want to be able to auto-update them when there is a later release...
14
by: iceman | last post by:
Hello, I have a windows service. I want to restart it after every 24 hour. Is it possible to restart the service programmatically(from the service itself) using the sercvice controller object?...
0
by: felecha | last post by:
Is there a way to write a Service so that it will fail? I'm working on a Service written in VB.Net, that supports an application we are building, and I want to make sure that it can restart...
5
by: scorpion53061 | last post by:
Is there a way that anyone knows to force a vb.net program to shut down and then restart itself?
3
by: Matt | last post by:
Is there an 'easy' way to have a service stop and restart itself? I currently have a seperate service running who's job is to watch the other service and restart it if there is a problem... can I...
2
by: Tedmond | last post by:
Dear all, I wrote a service by C# but I found the service is not quite stable. I want to add some code that refresh or restart the service itself for a fixed period. Does anyone know how to...
2
by: harshvardhan3 | last post by:
I have a requirement. when we start a java program we should get a frame where we have restart button. when we press that button the program should exit from JVM and again start execution.
8
by: =?Utf-8?B?TWlrZVo=?= | last post by:
How Can Windows Service Application Reatarts itself? Thanks.
1
by: Sriram Srivatsan | last post by:
Hi We are trying to build an application where we render some of the .aspx pages from the database using a class derived from System.Web.Hosting.VirtualPathProvider. Users configure the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.