public void restartApplication() throws URISyntaxException, IOException { /* where is java and local app ? */ final String javaBin = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java"; final File currentJar = new File( getClass().getProtectionDomain().getCodeSource() .getLocation().toURI() ); /* is it a jar file ? */ if( !currentJar.getName().endsWith(".jar") ) return; /* build command: java -jar application.jar */ final ArrayListcommand = new ArrayList (); command.add( javaBin ); command.add( "-jar" ); command.add( currentJar.getPath() ); /* run it - and close current */ final ProcessBuilder builder = new ProcessBuilder( command ); builder.start(); System.exit(0); }
Microsoft AX 2012, X++, C#, SQL server, SSRS, Java, JavaFX, Oracle, PL/SQL, Delphi - codes examples, step-by-step tutorials, experiences.
Wednesday, November 29, 2017
JAVA - How restart java application
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment