{"record":{"id":"64aa992effde027d","repo":"apache/flink","slug":"java-program-should-be-specified-a-jar-file","errorCode":null,"errorMessage":"Java program should be specified a JAR file.","messagePattern":"Java program should be specified a JAR file\\.","errorType":"validation","errorClass":"CliArgsException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/cli/ProgramOptions.java","lineNumber":137,"sourceCode":"\n    protected String[] extractProgramArgs(CommandLine line) {\n        String[] args =\n                line.hasOption(ARGS_OPTION.getOpt())\n                        ? line.getOptionValues(ARGS_OPTION.getOpt())\n                        : line.getArgs();\n\n        if (args.length > 0 && !line.hasOption(JAR_OPTION.getOpt())) {\n            jarFilePath = args[0];\n            args = Arrays.copyOfRange(args, 1, args.length);\n        }\n\n        return args;\n    }\n\n    public void validate() throws CliArgsException {\n        // Java program should be specified a JAR file\n        if (getJarFilePath() == null) {\n            throw new CliArgsException(\"Java program should be specified a JAR file.\");\n        }\n        if (savepointSettings.getRecoveryClaimMode().equals(RecoveryClaimMode.LEGACY)) {\n            System.out.printf(\n                    \"Warning: The %s restore mode is deprecated, please use %s or\"\n                            + \" %s mode instead.%n\",\n                    RecoveryClaimMode.LEGACY, RecoveryClaimMode.CLAIM, RecoveryClaimMode.NO_CLAIM);\n        }\n    }\n\n    public String getJarFilePath() {\n        return jarFilePath;\n    }\n\n    public String getEntryPointClassName() {\n        return entryPointClass;\n    }\n\n    public List<URL> getClasspaths() {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/cli/ProgramOptions.java#L119-L155","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nflink run -c com.example.MyJob\n\n# after\nflink run -c com.example.MyJob ./target/myjob.jar","handlingStrategy":"validation","validationCode":"if (jarFilePath == null || jarFilePath.isBlank()) {\n    throw new IllegalArgumentException(\n        \"A JAR file path is required. Usage: flink run [options] <jarPath>\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","user-input","job-submission"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}