Esempio n. 1
0
  private void restartApp() {
    if (!updateThis()) {
      JOptionPane.showMessageDialog(
          getProgressPanel().getParent(),
          "The update has completed successfully, but the control panel "
              + "was unable to restart itself automatically. Please close then "
              + "restart the control panel manually to use the updated version.",
          "Update Completed",
          JOptionPane.WARNING_MESSAGE);
      return;
    }
    String javaBin =
        System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
    try {
      String appPath = FileUtil.getJarFile().getPath();
      String newJarName = _differ.getNewJarName();
      if (!(newJarName == null || appPath.endsWith(newJarName))) {
        appPath = getPathForNewAppName(appPath);
        if (appPath == null) {
          throw new IllegalArgumentException();
        }
      }

      java.util.List<String> command = new ArrayList<String>();
      command.add(javaBin);
      command.add("-jar");
      command.add(FileUtil.getJarFile().getPath());
      command.add("-updateCompleted");

      ProcessBuilder builder = new ProcessBuilder(command);
      builder.start();
      System.exit(0);
    } catch (Exception e) {
      showError("Failed to restart the Control Panel. Please restart manually.");
    }
  }
Esempio n. 2
0
 private String getPathForNewAppName(String appPath) {
   return appPath == null ? null : getPathPart(appPath) + _differ.getNewJarName();
 }