I am currently creating a Java application with a UI created using Java FX. My application's interface is divided into three separate tabs. On the first tab, I have a lot of buttons that launch other applications. My goal is for the user to launch these applications in a certain order, so the succeeding buttons are disabled out until the previous application's process has finished, then they are enabled. I have accomplished this by using the lines
Process p = Runtime.getRuntime().exec(application);
p.waitFor();
Then the controller enables the next button in the interface. My problem arises when the launched application is running. Due to my application waiting for the process to end, task manager shows my Java application as not responding, and you are unable to navigate to the other tabs. Of course when the launched application has finished, my application functions normally.
I was thinking that it's due to the main thread being blocked as it's waiting on a process to finish. Would the best solution be to run this process on a separate thread so the rest of the application is usable while waiting on a launched process to finish?