0

I want to have a button in my application that simply reloads the application.

Essentially, I just want to re-run the JAR and System.exit() - but I don't want to do this using Runtime.exec() because I need it to work on multiple OS.

I can't really come up with anything.

John Smith
  • 139
  • 4
  • 12
  • http://stackoverflow.com/questions/4159802/how-can-i-restart-a-java-application – Floris Velleman Feb 15 '13 at 22:26
  • 1
    he said he doesn't want to use `Runtime.exec()`, that is pretty similar to `ProcessBuilder.start()`, so it's not the same question – Luigi R. Viggiano Feb 15 '13 at 22:41
  • 1
    maybe you should think about your application design. do you really need to reload the whole thing? why can't you just `null` those things you want to recreate and then create new instances? (well, to reassign them to `null` isn't needed here, it's more a metaphoric meaning) – Zhedar Feb 15 '13 at 22:56

1 Answers1

0

You could just change which is your main class, and have your old main class shut down after writing to a file, or have it return a Boolean, to show whether the button was pressed or not, so the new main class can simply have a while loop starting up your old main class.

Ben Hack
  • 91
  • 10