title: How can I implement the 'restart application' feature in Java
body: <p>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?<br>
  This is what I have tried:<br></p>
  
  <pre><code>int o = JOptionPane.showConfirmDialog(
                                  frame,
                                  "&lt;html&gt;The previously selected preferences have been changed.&lt;br&gt;Watch must restart for the changes to take effect.&lt;br&gt; Restart now?&lt;/html&gt;",
                                  "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();
  </code></pre>
  
  <p>However, this doesn't seem to work. The application just terminates. What am I missing here? Thanks in advance!</p>