{"record":{"id":"96f0695d5b9f43f9","repo":"HMCL-dev/HMCL","slug":"missing-java-executable-file","errorCode":null,"errorMessage":"Missing java executable file","messagePattern":"Missing java executable file","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/java/JavaInfo.java","lineNumber":104,"sourceCode":"    }\n\n    public static <F, E extends ArchiveEntry> JavaInfo fromArchive(ArchiveFileTree<F, E> tree) throws IOException {\n        if (tree.getRoot().getSubDirs().size() != 1 || !tree.getRoot().getFiles().isEmpty())\n            throw new IOException();\n\n        ArchiveFileTree.Dir<E> jdkRoot = tree.getRoot().getSubDirs().values().iterator().next();\n        E releaseEntry = jdkRoot.getFiles().get(\"release\");\n        if (releaseEntry == null)\n            throw new IOException(\"Missing release file\");\n\n        JavaInfo info;\n        try (BufferedReader reader = new BufferedReader(new InputStreamReader(tree.getInputStream(releaseEntry), StandardCharsets.UTF_8))) {\n            info = JavaInfo.fromReleaseFile(reader);\n        }\n\n        ArchiveFileTree.Dir<E> binDir = jdkRoot.getSubDirs().get(\"bin\");\n        if (binDir == null || binDir.getFiles().get(info.getPlatform().getOperatingSystem().getJavaExecutable()) == null)\n            throw new IOException(\"Missing java executable file\");\n\n        return info;\n    }\n\n    public static String normalizeVendor(String vendor) {\n        if (vendor == null)\n            return null;\n\n        return switch (vendor) {\n            case \"N/A\" -> null;\n            case \"Oracle Corporation\" -> \"Oracle\";\n            case \"Azul Systems, Inc.\" -> \"Azul\";\n            case \"IBM Corporation\", \"International Business Machines Corporation\", \"Eclipse OpenJ9\" -> \"IBM\";\n            case \"Eclipse Adoptium\" -> \"Adoptium\";\n            case \"Amazon.com Inc.\" -> \"Amazon\";\n            default -> vendor;\n        };\n    }","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/java/JavaInfo.java#L86-L122","documentation":"After parsing the release file, JavaInfo.fromArchive verifies the JDK directory contains a bin/ subdirectory with the platform's java executable (java, javaw.exe, etc.). It throws IOException(\"Missing java executable file\") when either bin/ is absent or the expected executable entry is missing, since the archive does not contain a runnable Java runtime.","triggerScenarios":"JavaInfo.fromArchive(tree) with an archive whose single root dir lacks a 'bin' subdirectory, or whose bin/ does not contain the executable named by info.getPlatform().getOperatingSystem().getJavaExecutable() (e.g. using a linux archive on Windows lookup, or a stripped image).","commonSituations":"Downloading a JDK for the wrong platform (no javaw.exe on Windows archives is fine, but a mismatched archive lookup fails); jlink custom runtimes missing bin/java; archives with executables under a different layout (e.g. Contents/Home on macOS).","solutions":["Verify the archive matches the target platform so the expected executable name (java vs javaw.exe) exists in bin/.","Use a full JDK/JRE distribution instead of a stripped or jlink-minimized image lacking bin/java.","For macOS, ensure the archive is laid out so bin/ and release are at the JDK root HMCL expects.","Re-download the archive; a truncated download may have dropped bin entries."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"ArchiveFileTree.Dir<?> binDir = tree.getRoot().getSubDirs().get(\"bin\");\nString exe = expectedPlatform.getOperatingSystem().getJavaExecutable();\nif (binDir == null || binDir.getFiles().get(exe) == null) {\n    throw new IOException(\"Archive JDK has no bin/\" + exe);\n}","typeGuard":null,"tryCatchPattern":"try {\n    JavaInfo info = JavaInfo.fromArchive(tree);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"Missing java executable\")) {\n        // verify archive platform matches target OS\n    }\n}","preventionTips":["Match the JDK archive platform to the target OS before parsing","Use complete JDK/JRE images that ship bin/java (or javaw.exe on Windows)","Verify downloads are not truncated (compare size/hash)"],"tags":["java","jdk","archive","executable"],"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-15T23:17:13.987Z"}