stanfordnlp/CoreNLP · error · IllegalArgumentException
-output is required
Error message
-output is required
What it means
After flag parsing, main validates its required arguments; if -output was never provided it throws IllegalArgumentException("-output is required"). The tool needs an output path for the rewritten trees, so it refuses to run without one.
Solutions
- Add -output <file> to the command line
- Verify the flag is spelled -output exactly (case-insensitive match only)
- Ensure no earlier parse error consumed the output path token
Example fix
// before // java ParseAndSetLabels -parser model.ser.gz -labels labels.txt -sentences s.txt // after // java ParseAndSetLabels -parser model.ser.gz -labels labels.txt -sentences s.txt -output labeled.txt
Defensive patterns
Strategy: validation
Validate before calling
if (!java.util.Arrays.asList(args).contains("-output")) throw new IllegalArgumentException("-output is required before running"); Try / catch
try {
ParseAndSetLabels.main(args);
} catch (IllegalArgumentException e) {
if ("-output is required".equals(e.getMessage())) System.err.println("Add -output <file> to the command line");
throw e;
} Prevention
- Validate CLI flags in wrapper scripts before invoking
- Keep a canonical command template with all required flags
- Check the exit message names the exact missing flag
When it happens
Trigger: Running ParseAndSetLabels.main without the -output flag (or with a flag spelling that failed to match, leaving outputFile null).
Common situations: Forgotten -output in batch scripts; typo'd flag silently skipped by the unknown-argument check earlier; scripts migrated from other tools with different output flags.
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
- Error: No dest file provided in properties or via command…
- Error: No training file provided in properties or via…
- Error: No training file provided in properties or via…
- Error: -train option must have treebankPath as first…
- -labels is required
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b291b60e97446387.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/tools/ParseAndSetLabels.java:240
} else if (args[argIndex].equalsIgnoreCase("-binarize")) {
binarize = true;
argIndex += 1;
} else if (args[argIndex].equalsIgnoreCase("-nobinarize")) {
binarize = false;
argIndex += 1;
} else if (args[argIndex].equalsIgnoreCase("-useLabelKeys")) {
useLabelKeys = true;
argIndex += 1;
} else if (args[argIndex].equalsIgnoreCase("-nouseLabelKeys")) {
useLabelKeys = false;
argIndex += 1;
} else {
throw new IllegalArgumentException("Unknown argument " + args[argIndex]);
}
}
if (outputFile == null) {
throw new IllegalArgumentException("-output is required");
}
if (sentencesFile == null && !useLabelKeys) {
throw new IllegalArgumentException("-sentences or -useLabelKeys is required");
}
if (sentencesFile != null && useLabelKeys) {
throw new IllegalArgumentException("Use only one of -sentences or -useLabelKeys");
}
if (labelsFile == null) {
throw new IllegalArgumentException("-labels is required");
}
ParserGrammar parser = loadParser(parserFile, taggerFile);
TreeBinarizer binarizer = null;
if (binarize) {
binarizer = TreeBinarizer.simpleTreeBinarizer(parser.getTLPParams().headFinder(), parser.treebankLanguagePack());
}
View on GitHub (pinned to 1b7edd19c4)