{"record":{"id":"4ba6e64c6feacdab","repo":"HMCL-dev/HMCL","slug":"illegal-command-line","errorCode":null,"errorMessage":"Illegal command line ","messagePattern":"Illegal command line ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java","lineNumber":678,"sourceCode":"        return Path.of(options.getNativesDir());\n    }\n\n    @Override\n    public ManagedProcess launch() throws IOException, InterruptedException {\n        Path nativeFolder = getNativeFolder();\n\n        final Command command = generateCommandLine(nativeFolder);\n\n        // To guarantee that when failed to generate launch command line, we will not call pre-launch command\n        List<String> rawCommandLine = command.commandLine.asList();\n\n        if (command.tempNativeFolder != null) {\n            Files.deleteIfExists(command.tempNativeFolder);\n            Files.createSymbolicLink(command.tempNativeFolder, nativeFolder.toAbsolutePath());\n        }\n\n        if (rawCommandLine.stream().anyMatch(StringUtils::isBlank)) {\n            throw new IllegalStateException(\"Illegal command line \" + rawCommandLine);\n        }\n\n        if (!options.isUseCustomNatives()) {\n            decompressNatives(command.javaNativeFolder);\n        }\n\n        if (isUsingLog4j())\n            extractLog4jConfigurationFile();\n\n        Path runDirectory = instance.getRunDirectory();\n\n        if (StringUtils.isNotBlank(options.getPreLaunchCommand())) {\n            ProcessBuilder builder = new ProcessBuilder(StringUtils.tokenize(options.getPreLaunchCommand(), getEnvVars(nativeFolder))).directory(runDirectory.toFile());\n            builder.environment().putAll(getEnvVars(nativeFolder));\n            SystemUtils.callExternalProcess(builder);\n        }\n\n        Process process;","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java#L660-L696","documentation":"DefaultLauncher.launch validates the fully assembled command line before executing the game: every token must be non-blank. If any element of rawCommandLine is blank (empty or whitespace-only string) it throws IllegalStateException(\"Illegal command line \" + rawCommandLine), protecting against launching java with empty arguments that corrupt the command.","triggerScenarios":"Calling launch() when the generated command contains an empty/whitespace argument — typically caused by blank entries in JVM arguments, game arguments, classpath, or empty custom Java/wrapper settings in the instance configuration.","commonSituations":"Users adding an empty custom JVM argument or game argument in instance settings; empty environment-derived substitution leaving blank tokens; misconfigured memory/encoding fields producing empty strings.","solutions":["Review instance JVM/game argument settings and remove blank or duplicate empty entries.","Check custom command prefixes (wrapper/pre-launch) for empty values and clear or fill them.","Print/log rawCommandLine (it is in the exception message) to identify which token is blank.","Reset the instance's advanced settings to defaults and re-add arguments carefully."],"exampleFix":"// before (instance settings)\n// jvmArgs: \"-Xmx4G,, -Dfoo=bar\"\n// after\n// jvmArgs: \"-Xmx4G -Dfoo=bar\"","handlingStrategy":"validation","validationCode":"List<String> args = commandLine.toString() != null ? List.of(commandLine.toString().split(\"\\s+\")) : List.of();\nboolean hasBlank = args.stream().anyMatch(String::isBlank);\nif (hasBlank) { // fix instance JVM/game argument settings first }","typeGuard":null,"tryCatchPattern":"try {\n    launcher.launch();\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Illegal command line\")) {\n        // inspect the printed command line; remove blank arguments from instance settings\n    }\n}","preventionTips":["Avoid empty entries in custom JVM/game argument lists","Trim user-supplied argument strings and drop blanks before saving settings","Check wrapper/prefix settings for empty values"],"tags":["launcher","command-line","validation","minecraft"],"backgroundTag":"invalid-argument-value","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}