poidasmith / winrun4j

WinRun4J Java Application Launcher
http://winrun4j.sourceforge.net
212 stars 63 forks source link

Restart an application again (after automatic update) #70

Open christoph-wulf opened 9 years ago

christoph-wulf commented 9 years ago

We've implemented an automatic update for a Scala and SWT based application we run with WinRun4J on Windows. The updater downloads the new JARs and overwrites the INI file for a new classpath at the next start. Afterwards the application exists and the user has to start the application again to use the updated version. I'd like to make that restart automatically. I can't just start the new application again from command line because of single.instance=window

Would it be possible to do somehow trigger this restart? I think Eclipse got a similar feature depending on the exit code.

neandrake commented 9 years ago

You could write out a batch script that sleeps for ~5 seconds and runs your application. Launch it from your application then immediately quit.

poidasmith commented 9 years ago

Agreed, it would also be simple to implement a Java main class/method to implement the restart generally. As neandrake suggested, it would work like:

  1. Java application A is ready to restart, record its process id (PID) .2 Java application A launches java restart application with args of the PID and then full command to execute
  2. Java restart application would wait for exit of process (with PID)
  3. Java restart application would execute the full command passed in on the command line
  4. Java restart application exits