stanfordnlp/CoreNLP · error · IllegalArgumentException

Must specify input with -input

Error message

Must specify input with -input

What it means

After argument parsing, ConvertGenderFile.main validates that an input path was provided; if input is still null it throws this IllegalArgumentException. The tool requires an explicit -input file of gender/number mappings.

Solutions

  1. Add -input <path-to-gender-file> to the command line
  2. Ensure a value follows the -input flag
  3. Verify the flag name is exactly -input

Example fix

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

Strategy: validation

Validate before calling

boolean hasInput = false;
for (int i = 0; i < args.length - 1; i++) if ("-input".equalsIgnoreCase(args[i]) && args[i+1] != null) { hasInput = true; break; }
if (!hasInput) throw new IllegalArgumentException("-input 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 -input flag (or with -input but no following value).

Common situations: Forgot the -input flag; provided only -output; flag followed by nothing because the value was omitted.

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/9c1f395a550727a1. Report an issue: GitHub.

Appendix: source

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

  private ConvertGenderFile() {} // static class

  public static void main(String[] args) throws IOException {
    String input = null;
    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;

View on GitHub (pinned to 1b7edd19c4)