Exemplo n.º 1
0
  /**
   * Saves the name of an executable on the system path or the path to an executable. <br>
   * <br>
   * <b>Note:</b> this will overwrite the previously saved value.
   *
   * @param executable The name of an executable on the system path or the path to an executable.
   * @return This instance of {@link ProcessBuilder}.
   */
  public ProcessBuilder withExecutable(final String executable) {
    if (StringUtil.isNullOrEmpty(executable)) {
      throw new IllegalArgumentException("executable cannot be null or empty");
    }

    this.executable = executable;
    return this;
  }
Exemplo n.º 2
0
  /**
   * Adds an environment variable with the provided name and value to the list of environment
   * variables to be set when the process is created.
   *
   * <p>Unless configured otherwise, these will be appended to the parent process' environment
   * variables.
   *
   * @param name The name of the environment variable to add.
   * @param value The value of the environment variable to add.
   * @return This instance of {@link ProcessBuilder}.
   */
  public ProcessBuilder addEnvironmentVariable(final String name, final String value) {
    if (StringUtil.isNullOrEmpty(name)) {
      throw new IllegalArgumentException("name cannot be null or empty");
    }
    if (value == null) {
      throw new IllegalArgumentException("value cannot be null");
    }

    this.env.addEnvironmentVariable(name, value);
    return this;
  }