Hello All.
I have a program that automatically restarts itself atfer a certain amount of time.
I am doing this to test some things out. The program is wrapped in a jar.
I run the jar from terminal with
java -jar ProgramName.jar
It will run and will output all the "System.out.println" outputs in terminal
When the program restarts itself, It stops outputing on terminal. It runs fine and everything, I just want to see the output. How would I accomplish this.
this is my restarting code.
public void Restart() throws IOException {
try {
final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
final File currentJar = new File(ProgramName.class.getProtectionDomain().getCodeSource().getLocation().toURI());
/* is it a jar file? */
if (!currentJar.getName().endsWith(".jar")) {
return;
}
/* Build command: java -jar application.jar */
final ArrayList<String> command = new ArrayList<>();
command.add(javaBin);
command.add("-jar");
command.add(currentJar.getPath());
final ProcessBuilder builder = new ProcessBuilder(command);
builder.start();
System.exit(0);
} catch (URISyntaxException ex) {
Logger.getLogger(ProgramName.class.getName()).log(Level.SEVERE, null, ex);
}
}
Any help would be appreciated.