code: private int resolveProcessId(final String processName, int id) throws IOException {
          final String jpsCommand = getJpsCommand();
          if(jpsCommand == null) {
              ProcessLogger.ROOT_LOGGER.jpsCommandNotFound(processName);
              return -1;
          }
          final Process p = Runtime.getRuntime().exec(jpsCommand);
          final List<String> processes = new ArrayList<>();
          final BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8));
          try {
              String line;
              // See if the process contains "jboss-modules.jar" and "-D[Server:server-one]"
              final String process = "-D[" + processName + "]";
              final String idParam = id < 0 ? null : "-D[pcid:" + id + "]";
              while ((line = input.readLine()) != null) {
                  if (line.contains(modulesJar) && line.contains(process)
                          && (idParam == null || line.contains(idParam))) {
                      processes.add(line);
                  }
              }
          } finally {
              StreamUtils.safeClose(input);
          }
          if(processes.size() == 1) {
              final String proc = processes.get(0);
              final int i = proc.indexOf(' ');
              return Integer.parseInt(proc.substring(0, i));
          }
          if(processes.isEmpty()) {
              ProcessLogger.ROOT_LOGGER.processNotFound(processName);
          } else {
              ProcessLogger.ROOT_LOGGER.multipleProcessesFound(processName);
          }
          return -1;
      }
docs: Iterate through all java processes and try to find the one matching to the given process id.
  This will return the resolved process-id or {@code -1} if not resolvable.
  
  @param processName the process name
  @param id the process integer id, or {@code -1} if this is not relevant
  @return the process id
  @throws IOException