code: public static String guessDefaultTerminal() {
          if (System.getProperty("os.name", "").equalsIgnoreCase("windows")) {
              return "cmd.exe";
          }
  
          String envPath = System.getenv("PATH");
          if (envPath == null) {
              throw new RuntimeException("Could not find enviroment PATH setting.");
          }
          String[] pathes = envPath.split(":");
  
          for (String term : TERMINAL_EMULATORS) {
              for (String path : pathes) {
                  File terminalExe = new File(concatFilePath(path, term));
                  if (terminalExe.exists() && terminalExe.canExecute()) {
                      return terminalExe.getAbsolutePath();
                  }
              }
          }
  
          return null;
      }
docs: Tries to find the "default" terminal emulator.
  This will be cmd.exe on windows and may vary on linux/unix systems depending on installed terminal programs.
  On linux/unix there is no generic way to find the default terminal,
  so all known terminal programs will be tried until any of them is found.
  @return String with terminal name or null if terminal could not be determined