Guest User

Untitled

a guest
Jun 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public void restartApplication()
  2. {
  3. final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
  4. final File currentJar = new File(UpdateReportElements.class.getProtectionDomain().getCodeSource().getLocation().toURI());
  5.  
  6. /* is it a jar file? */
  7. if(!currentJar.getName().endsWith(".jar"))
  8. return;
  9.  
  10. /* Build command: java -jar application.jar */
  11. final ArrayList<String> command = new ArrayList<String>();
  12. command.add(javaBin);
  13. command.add("-jar");
  14. command.add(currentJar.getPath());
  15.  
  16. final ProcessBuilder builder = new ProcessBuilder(command);
  17. builder.start();
  18. System.exit(0);
  19. }
Add Comment
Please, Sign In to add comment