File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Java self restart Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java self restart" Watch "Java self restart" New topic
Author

Java self restart

Glen Divers
Ranch Hand

Joined: Jan 21, 2010
Posts: 61
Hi

I'm working on a self-updating application that checks for updates at app startup. I've got the version checking and download of new .jars from the server working. How do I tell my app to restart itself?

Regards
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Gilbert Ostlethwaite wrote:Hi

I'm working on a self-updating application that checks for updates at app startup. I've got the version checking and download of new .jars from the server working. How do I tell my app to restart itself?

Regards


No need to re-invent the wheel - WebStart.
Glen Divers
Ranch Hand

Joined: Jan 21, 2010
Posts: 61
I should've added that Web-Start is not an option at the moment (mainly for boring, irrelevant, political reasons).

Regards
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

But you are re-inventing WebStart! I have great difficulty in believing that your home-grown probably buggy WebStart is more acceptable than the Sun/Oracle WebStart. In your position, I would go back to whoever has made the decision not to use WebStart and tell them that the decision makes no sense.

P.S. Use a boot-strapping application that downloads the upgrade if it exists prior to running the main application.
Glen Divers
Ranch Hand

Joined: Jan 21, 2010
Posts: 61
While I cannot find anything in your argument to disagree with, sometimes the real world can prove to be capricious. In this particular instance, the client, who are paying, have stipulated no Web-Start. The ability to remonstrate lies several pay grades upward - and, regrettably, that puts me in the hands of "Sales".

Regards
alex delaguardia
Greenhorn

Joined: Sep 07, 2004
Posts: 5
See if this helps:
1- Run you application using a command file.

Inside your command file put something like this.

:restart
JRE\jre1.6.0_07\bin\java -cp .;.\program_name.jar
if exist fileName GOTO restart

before you exit you program for restarting write a file ("fileName") to the system.

Basically as long as the fileName exits the program will restart again. (you will need to remove the file after the application start).
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

Ah well... let's take the passive-aggressive method then. Just call System.exit(0) after the application has been running for a minute; and have a script which calls the application again as soon as it terminates.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

Gilbert Ostlethwaite wrote:I'm working on a self-updating application that checks for updates at app startup. I've got the version checking and download of new .jars from the server working. How do I tell my app to restart itself?


Actually, what I just posted doesn't really make sense in the context of actually having read the original post.

If you're checking for updates at the time the application starts up, I don't see why you need to tell the application to restart itself at all. Wouldn't you just check for new versions, download them if present, and then start the application? If you're tasked with reinventing Web Start, then that's what Web Start does so that's what you should do.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java self restart
 
Similar Threads
Tomcat class file problem
Registering Servlets in web.xml dynamically at runtime
problem with EL in my JSP page
When a Java Bean is modified do we need to restart Apache Tomcat?
HttpStatsuError