In many software, after we make any changes, the software has to be restarted for the changes to take effect, and sometimes, there is an option to restart the software automatically. How can I implement this in Java?
This is what I have tried:
int o = JOptionPane.showConfirmDialog(
frame,
"<html>The previously selected preferences have been changed.<br>Watch must restart for the changes to take effect.<br> Restart now?</html>",
"Restart now?", JOptionPane.YES_NO_OPTION);
if(o == JOptionPane.YES_OPTION) {
try {
Process p = new ProcessBuilder("java", "Watch").start();
} catch(IOException e) {
e.printStackTrace();
}
frame.dispose();
However, this doesn't seem to work. The application just terminates. What am I missing here? Thanks in advance!