stanfordnlp/CoreNLP · error · IllegalArgumentException

Must specify output with -output

Error message

Must specify output with -output

What it means

ConvertGenderFile.main validates that an output path was provided; if output is null after parsing, it throws this IllegalArgumentException. The converted gender map must be written somewhere via -output.

Solutions

  1. Add -output <target-file> to the command line
  2. Ensure a value follows the -output flag
  3. Double-check flag spelling is exactly -output

Example fix

// before
java ConvertGenderFile -input gender.counts
// after
java ConvertGenderFile -input gender.counts -output gender.ser
Defensive patterns

Strategy: validation

Validate before calling

boolean hasOutput = false;
for (int i = 0; i < args.length - 1; i++) if ("-output".equalsIgnoreCase(args[i]) && args[i+1] != null) { hasOutput = true; break; }
if (!hasOutput) throw new IllegalArgumentException("-output is required");

Try / catch

try {
  ConvertGenderFile.main(args);
} catch (IllegalArgumentException e) {
  System.err.println("Usage: ConvertGenderFile -input <in> -output <out>");
  System.exit(2);
}

Prevention

When it happens

Trigger: Running ConvertGenderFile without the -output flag (or with -output missing its value).

Common situations: Forgot the -output flag while specifying -input; value omitted after -output; assumption that a default output file exists (it does not).

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/9654082832e5b1f9. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/dcoref/util/ConvertGenderFile.java:46

    String output = null;
    for (int argIndex = 0; argIndex < args.length; ) {
      if (args[argIndex].equalsIgnoreCase("-input")) {
        input = args[argIndex + 1];
        argIndex += 2;
      } else if (args[argIndex].equalsIgnoreCase("-output")) {
        output = args[argIndex + 1];
        argIndex += 2;
      } else {
        throw new IllegalArgumentException("Unknown argument " + args[argIndex]);
      }
    }

    if (input == null) {
      throw new IllegalArgumentException("Must specify input with -input");
    }

    if (output == null) {
      throw new IllegalArgumentException("Must specify output with -output");
    }

    Map<List<String>, Gender> genderNumber = Generics.newHashMap();

    BufferedReader reader = IOUtils.readerFromString(input);
    for (String line; (line = reader.readLine()) != null; ) {
      String[] split = line.split("\t");
      String[] countStr = split[1].split(" ");

      int male = Integer.parseInt(countStr[0]);
      int female = Integer.parseInt(countStr[1]);
      int neutral = Integer.parseInt(countStr[2]);

      Gender gender = Gender.UNKNOWN;
      if (male * 0.5 > female + neutral && male > 2) {
        gender = Gender.MALE;
      } else if (female * 0.5 > male + neutral && female > 2) {
        gender = Gender.FEMALE;

View on GitHub (pinned to 1b7edd19c4)