{"record":{"id":"07df8abe0ed4b1b6","repo":"pxb1988/dex2jar","slug":"error-options-options-is-required","errorCode":null,"errorMessage":"ERROR: Options: ${options} is required","messagePattern":"ERROR: Options: (.+?) is required","errorType":"console","errorClass":"HelpException","httpStatus":null,"severity":"error","filePath":"d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java","lineNumber":478,"sourceCode":"        this.remainingArgs = remainsOptions.toArray(new String[0]);\n        if (this.printHelp) {\n            throw new HelpException();\n        }\n        if (!requiredOpts.isEmpty()) {\n            StringBuilder sb = new StringBuilder();\n            sb.append(\"ERROR: Options: \");\n            boolean first = true;\n            for (Option option : requiredOpts) {\n                if (first) {\n                    first = false;\n                } else {\n                    sb.append(\" and \");\n                }\n                sb.append(option.getOptAndLongOpt());\n            }\n            sb.append(\" is required\");\n            System.err.println(sb);\n            throw new HelpException();\n        }\n\n    }\n\n    protected void usage() {\n        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8), true);\n\n        final int maxLength = 80;\n        final int maxPaLength = 40;\n        out.println(this.cmdName + \" -- \" + desc);\n        out.println(\"usage: \" + this.cmdName + \" \" + cmdLineSyntax);\n        if (this.optMap.size() > 0) {\n            out.println(\"options:\");\n        }\n        // [PART.A.........][Part.B\n        // .-a,--aa.<arg>...desc1\n        // .................desc2\n        // .-b,--bb","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java#L460-L496","documentation":"BaseCmd's argument parser (parseSetArgs) collects required command-line options before dispatching to a subcommand. When one or more options marked as required are absent from the parsed command line, it prints the full list of missing options to stderr and throws HelpException. This is the library's standard way of aborting with usage help instead of proceeding with incomplete configuration.","triggerScenarios":"Running a dex2jar tool command (e.g. d2j-dex2jar.sh, d2j-jar2dex) via BaseCmd.doMain without supplying a mandatory option such as the input/output file, e.g. omitting -f/--force style required flags or forgetting the input dex/jar argument.","commonSituations":"Typing the command with too few arguments, wrapping an old wrapper script that passes stale flags, forgetting an option that was newly made required in a version update, or misplacing the argument so it is not attached to the required option.","solutions":["Run the command with no arguments or -h to print usage and see which options are required.","Add the missing option(s) listed in the stderr message, e.g. d2j-dex2jar.sh -o out.jar in.apk.","Check for typos in option names; unknown options are dropped, leaving required ones unsatisfied.","If invoking programmatically, pass options through BaseCmd.doMain with the correct -opt value pairs.","If the requirement changed in a newer dex2jar release, update wrapper scripts to supply the new required option."],"exampleFix":"// before\nd2j-dex2jar.sh classes.dex -f\n// (missing required -o)\n\n// after\nd2j-dex2jar.sh -f -o classes-dex2jar.jar classes.dex","handlingStrategy":"validation","validationCode":"// Check required options before invoking the tool\nString[] args = {\"-f\"}; // missing -o\nboolean hasOutput = java.util.Arrays.asList(args).contains(\"-o\");\nif (!hasOutput) {\n    System.err.println(\"Required option -o <output> is missing; see tool usage.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    MyCmd.doMain(args);\n} catch (com.googlecode.dex2jar.tools.BaseCmd.HelpException e) {\n    // usage already printed to stderr; show help and exit non-zero\n    System.exit(2);\n}","preventionTips":["Always run the tool with -h first to enumerate required options.","Supply both input and -o output explicitly in wrapper scripts.","Validate option count in scripts before exec'ing the tool.","After upgrading dex2jar, diff the usage output for newly required options."],"tags":["cli","arguments","dex2jar"],"backgroundTag":"missing-required-option","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}