{"record":{"id":"d89d59ab369fc96e","repo":"HMCL-dev/HMCL","slug":"minecraft-client-jar-not-found-minecraftjar-d89d59","errorCode":null,"errorMessage":"Minecraft client JAR not found: ${minecraftJar}","messagePattern":"Minecraft client JAR not found: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineInstallTask.java","lineNumber":154,"sourceCode":"    @Override\n    public Collection<Task<?>> getDependents() {\n        return dependents;\n    }\n\n    @Override\n    public Collection<Task<?>> getDependencies() {\n        return dependencies;\n    }\n\n    @Override\n    public boolean isRelyingOnDependencies() {\n        return false;\n    }\n\n    @Override\n    public void execute() throws Exception {\n        if (!Files.isRegularFile(minecraftJar)) {\n            throw new IOException(\"Minecraft client JAR not found: \" + minecraftJar);\n        }\n        Path installerFile = Objects.requireNonNull(dest);\n        String originalMainClass = manifest.mainClass();\n        if (!GameComponentAnalyzer.FORGE_OPTIFINE_MAIN.contains(originalMainClass))\n            throw new UnsupportedInstallationException(UnsupportedInstallationException.UNSUPPORTED_LAUNCH_WRAPPER);\n\n        List<Library> libraries = new ArrayList<>(4);\n        libraries.add(optiFineLibrary);\n\n        Path optiFineInstallerLibraryPath = gameRepository.getLayout().getLibraryFile(manifest.id(), optiFineInstallerLibrary);\n        FileUtils.copyFile(installerFile, optiFineInstallerLibraryPath);\n\n        try (FileSystem fs2 = CompressingUtils.createWritableZipFileSystem(optiFineInstallerLibraryPath)) {\n            Files.deleteIfExists(fs2.getPath(\"/META-INF/mods.toml\"));\n        }\n\n        // Install launch wrapper modified by OptiFine\n        boolean hasLaunchWrapper = false;","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineInstallTask.java#L136-L172","documentation":"Thrown at the start of OptiFineInstallTask.execute() when the Minecraft client JAR path is not a regular file. OptiFine's patcher needs the vanilla client jar to operate on, so installation aborts with an IOException.","triggerScenarios":"Calling execute() when minecraftJar was not downloaded, was deleted, or resolves to a non-regular file (directory/broken symlink).","commonSituations":"Vanilla install never completed, user moved/renamed the .minecraft directory, wrong repository path, or a cleanup step removed the client jar.","solutions":["Download/restore the vanilla client JAR before installing OptiFine.","Verify Files.isRegularFile(minecraftJar) before launching the task.","Recreate the game version so the launcher re-downloads the client jar."],"exampleFix":"// before\noptiFineInstallTask.execute(); // IOException if jar missing\n// after\nif (!Files.isRegularFile(clientJar)) {\n    await(new VanillaInstallTask(dep, manifest, 'client', gameVersion));\n}\noptiFineInstallTask.execute();","handlingStrategy":"validation","validationCode":"if (!Files.isRegularFile(minecraftJar))\n    throw new IllegalStateException(\"Minecraft client JAR must exist before installing OptiFine\");","typeGuard":null,"tryCatchPattern":"try {\n    await(task);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Minecraft client JAR not found\")) {\n        await(new VanillaInstallTask(...)); // restore client jar, then retry\n        await(task);\n    }\n}","preventionTips":["Download the vanilla client before OptiFine installation","Do not move/rename the game directory mid-install","Verify jar existence before scheduling the task"],"tags":["file-not-found","optifine","minecraft-client","installer"],"backgroundTag":"file-not-found","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}