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:

  1. 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
  2. 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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -