This is from the other topic but in the opposite to the accepted question in this other topic this one really works.
public void restart() {
StringBuilder cmd = new StringBuilder();
cmd.append(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java ");
for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
cmd.append(jvmArg + " ");
}
cmd.append("-cp ").append(ManagementFactory.getRuntimeMXBean().getClassPath()).append(" ");
cmd.append(Window.class.getName()).append(" ");
try {
Runtime.getRuntime().exec(cmd.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.exit(0);
}
27/02/2018: I believe that Mark posted better solution: https://stackoverflow.com/a/48992863/1123020