0

I need to restart a JavaFX Application, which is a standalone desktop application launched by a single JAR, by a specific action within the application that throws a specific exit code upon closure of said application. This could be a button, dialog, what-have-you, I just need it to exit the program while setting the exit code to something specific to designate that restarting the application is what I desire upon exit.

I'm going off of this question: Restart an Application in JavaFx

I have zero idea how to set the exit code in JavaFX, and can't find it in the Platform or Application classes. I'm not even sure if this is the best way to restart a JavaFX application which is deployed in the manner I described above. Any help is greatly appreciated. Also, the application is run on Ubuntu 14, for the most part.

Community
  • 1
  • 1

1 Answers1

0

I haven't tried, but you could try:

public static void main(String[] args) {
     Application.launch(MyApp.class, args);
}

From the Javadoc:

The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.

Once it returns you could maybe detect somehow if you need to perform a restart and either call the launch method again (I guess this should be possible once it returns) or set an exit code using System.exit() and handle the restart in some script.

Puce
  • 37,247
  • 13
  • 80
  • 152