/**
   * Locates the executable for the jarsigner tool.
   *
   * @Copy&paste from org.apache.maven.plugins.jarsigner.AbstractJarsignerMojo
   * @return The executable of the jarsigner tool, never <code>null<code>.
   */
  private String getExecutable() {
    String command = "jarsigner" + (Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : "");

    String executable =
        findExecutable(
            command, System.getProperty("java.home"), new String[] {"../bin", "bin", "../sh"});

    if (executable == null) {
      try {
        Properties env = CommandLineUtils.getSystemEnvVars();

        String[] variables = {"JDK_HOME", "JAVA_HOME"};

        for (int i = 0; i < variables.length && executable == null; i++) {
          executable =
              findExecutable(command, env.getProperty(variables[i]), new String[] {"bin", "sh"});
        }
      } catch (IOException e) {
        if (getLog().isDebugEnabled()) {
          getLog()
              .warn("Failed to retrieve environment variables, cannot search for " + command, e);
        } else {
          getLog().warn("Failed to retrieve environment variables, cannot search for " + command);
        }
      }
    }

    if (executable == null) {
      executable = command;
    }

    return executable;
  }