HMCL-dev/HMCL · error · IOException
Platform is mismatch: expected
Error message
Platform is mismatch: expected
What it means
getInstallJavaTask validates that the Java runtime produced by JavaInstallTask reports the same platform that was requested. If the unpacked JDK's info().getPlatform() differs from the requested Platform (e.g. wrong architecture or OS), an IOException is thrown and the installation is rejected.
Solutions
- Re-run the installation so HMCL re-resolves the correct JDK for the requested platform
- Verify the JDK archive's architecture/OS matches the target platform before installing
- Check the Mojang/adoptium mirror serving the archive is returning the right build
- If the platform string is wrong, pass the correct Platform to getInstallJavaTask
Example fix
// before task = repo.getInstallJavaTask(Platform.WINDOWS_X86_64, name, update, archive); // after task = repo.getInstallJavaTask(Platform.SYSTEM_PLATFORM, name, update, archive); // let HMCL pick matching platform
Defensive patterns
Strategy: try-catch
Try / catch
try {
Task<JavaRuntime> task = repo.getInstallJavaTask(platform, name, update, archiveFile);
} catch (IOException e) {
if (e.getMessage().startsWith("Platform is mismatch")) {
ui.reportWrongArchitectureDownload();
} else {
throw e;
}
} Prevention
- Always use Platform.SYSTEM_PLATFORM (or equivalent) instead of hardcoding a platform
- Verify the JDK download source returns builds matching the requested platform
- Delete partial/corrupted JDK archives before retrying installation
When it happens
Trigger: Calling getInstallJavaTask(platform, name, update, archiveFile) where the downloaded/extracted JDK binary is built for a different OS or CPU architecture than the requested platform — e.g. requesting windows-x86_64 but the archive contains an ARM64 JDK, or downloading on a mismatched mirror.
Common situations: Wrong architecture JDK chosen (x86 vs arm64 vs x86_64); misconfigured download source serving the wrong platform; corrupted or mislabeled JDK archive; user manually placed a wrong-arch archive.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- name existing
- Texture url is empty
- Failed to download texture
- Failed to find current HMCL location
- Failed to get Java info from
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/19e448fd88f71ebf.
Report an issue: GitHub.
Appendix: source
Thrown at HMCL/src/main/java/org/jackhuang/hmcl/java/HMCLJavaRepository.java:194
}
} else if (file instanceof MojangJavaRemoteFiles.RemoteDirectory) {
files.put(path, new JavaLocalFiles.LocalDirectory());
} else if (file instanceof MojangJavaRemoteFiles.RemoteLink) {
files.put(path, new JavaLocalFiles.LocalLink(((MojangJavaRemoteFiles.RemoteLink) file).getTarget()));
}
});
JavaManifest manifest = new JavaManifest(info, update, files);
JsonUtils.writeToJsonFile(getManifestFile(platform, gameJavaVersion), manifest);
return JavaRuntime.of(executable, info, true);
});
}
public Task<JavaRuntime> getInstallJavaTask(Platform platform, String name, Map<String, Object> update, Path archiveFile) {
Path javaDir = getJavaDir(platform, name);
return new JavaInstallTask(javaDir, update, archiveFile).thenApplyAsync(result -> {
if (!result.info().getPlatform().equals(platform))
throw new IOException("Platform is mismatch: expected " + platform + " but got " + result.info().getPlatform());
Path executable = javaDir.resolve("bin").resolve(platform.getOperatingSystem().getJavaExecutable()).toRealPath();
JsonUtils.writeToJsonFile(getManifestFile(platform, name), result);
return JavaRuntime.of(executable, result.info(), true);
});
}
@Override
public Task<Void> getUninstallJavaTask(Platform platform, String name) {
return Task.runAsync(() -> {
Files.deleteIfExists(getManifestFile(platform, name));
FileUtils.deleteDirectory(getJavaDir(platform, name));
});
}
@Override
public Task<Void> getUninstallJavaTask(JavaRuntime java) {
return Task.runAsync(() -> {View on GitHub (pinned to 24702dc5a0)