apache/flink · error · CliArgsException
Java program should be specified a JAR file.
Error message
Java program should be specified a JAR file.
What it means
Thrown by ProgramOptions.validate() when getJarFilePath() returns null, meaning the user ran `flink run` without specifying a JAR file to execute. Flink needs a main JAR containing the job's entry point. The validation runs after all option parsing is complete, checking the final resolved jarFilePath.
Source
Thrown at flink-clients/src/main/java/org/apache/flink/client/cli/ProgramOptions.java:137
protected String[] extractProgramArgs(CommandLine line) {
String[] args =
line.hasOption(ARGS_OPTION.getOpt())
? line.getOptionValues(ARGS_OPTION.getOpt())
: line.getArgs();
if (args.length > 0 && !line.hasOption(JAR_OPTION.getOpt())) {
jarFilePath = args[0];
args = Arrays.copyOfRange(args, 1, args.length);
}
return args;
}
public void validate() throws CliArgsException {
// Java program should be specified a JAR file
if (getJarFilePath() == null) {
throw new CliArgsException("Java program should be specified a JAR file.");
}
if (savepointSettings.getRecoveryClaimMode().equals(RecoveryClaimMode.LEGACY)) {
System.out.printf(
"Warning: The %s restore mode is deprecated, please use %s or"
+ " %s mode instead.%n",
RecoveryClaimMode.LEGACY, RecoveryClaimMode.CLAIM, RecoveryClaimMode.NO_CLAIM);
}
}
public String getJarFilePath() {
return jarFilePath;
}
public String getEntryPointClassName() {
return entryPointClass;
}
public List<URL> getClasspaths() {View on GitHub (pinned to 2f3c205e92)
Solutions
- Add the JAR path as a positional argument: `flink run ./myjob.jar`
- Use the -j/--jar option explicitly: `flink run -j ./myjob.jar`
- Ensure the JAR path variable in scripts is non-empty before invoking
Example fix
# before flink run -c com.example.MyJob # after flink run -c com.example.MyJob ./target/myjob.jar
Defensive patterns
Strategy: validation
Validate before calling
if (jarFilePath == null || jarFilePath.isBlank()) {
throw new IllegalArgumentException(
"A JAR file path is required. Usage: flink run [options] <jarPath>");
} Prevention
- Always include the JAR path as a positional argument in flink run commands
- Validate that script variables resolving to the JAR path are non-empty
- Use -j/--jar explicitly to avoid ambiguity with options
When it happens
Trigger: Running `flink run` with no positional argument and no -j/--jar option; all arguments consumed by options (e.g., `-p 4 -c MyClass`) with nothing left for the JAR path.
Common situations: User forgets the JAR path; variable in a script that should expand to the JAR path is empty; user runs `flink run -c com.example.Job` but omits the JAR.
Related errors
- Missing JobId
- Bad syntax for classpath: {}
- The parallelism must be a positive number: {}
- No cluster id was specified. Please specify a cluster to whi
- The configuration directory '{}', specified in the '{}' envi
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/64aa992effde027d.
Report an issue: GitHub.