Run jar from within a Java application -
i trying build simple auto updater application. checking local application version against remote version. if there newer version want start updater.jar - downloads , replaces old application.
my problem cannot seem updater.jar start if there new version.
the code using is:
runtime runtime = runtime.getruntime(); try { process proc = runtime.exec("java -jar updater.jar"); } catch (ioexception ex) { logger.getlogger(splash.class.getname()).log(level.severe, null, ex); } system.exit(0);
the application exits updater.jar never launched..
any ideas?
your child process exiting when parent process exits.
when launch process should usually:
- consume stdout/stderr child process. if don't child process can block waiting output consumed. should consume in separate threads. see this answer more details
- use
process.waitfor()
capture exit code child process
it looks me want spawn updater, let perform download , exit parent process. more complex platform dependent (e.g. spawning background process , disowning it)
Comments
Post a Comment