HMCL-dev/HMCL · error · UnsupportedPlatformException
Incompatible platform: " + javaRuntime.getPlatform()
Error message
Incompatible platform: " + javaRuntime.getPlatform()
What it means
JavaManager.getAddJavaTask wraps the async 'add a Java runtime from a binary path' flow. After resolving the binary into a JavaRuntime, it checks the detected platform (OS + architecture) against the current machine via JavaManager.isCompatible. If the runtime's platform doesn't match the running OS/arch, it throws UnsupportedPlatformException with the offending platform in the message, refusing to register a Java that cannot be used here.
Solutions
- Use a Java runtime built for the current operating system and architecture; delete or stop referencing the foreign binary
- Re-check the binary path given to getAddJavaTask — it may resolve through a symlink to another platform's JRE
- If the architecture differs but is intentional (e.g. Rosetta/Windows-on-ARM translation), verify the platform detection in JavaRuntime/Platform.getPlatform and update code to allow translated architectures
- Catch UnsupportedPlatformException around the Task and surface a user-facing message asking them to pick a local Java
Example fix
// before
Task<JavaRuntime> t = JavaManager.getAddJavaTask(Path.of("/opt/java/windows/bin/java.exe"));
// after
Platform p = JavaManager.getJavaExecutablePlatform(Path.of("/usr/lib/jvm/java-17/bin/java"));
if (JavaManager.isCompatible(p)) {
Task<JavaRuntime> t = JavaManager.getAddJavaTask(Path.of("/usr/lib/jvm/java-17/bin/java"));
} Defensive patterns
Strategy: try-catch
Validate before calling
Platform p = JavaManager.getJavaExecutablePlatform(binary);
if (!JavaManager.isCompatible(p)) throw new IllegalArgumentException("Java binary is not for this OS/arch: " + p); Type guard
static boolean isLocalJava(Path binary) {
Platform p = JavaManager.getJavaExecutablePlatform(binary);
return p != null && JavaManager.isCompatible(p);
} Try / catch
try {
JavaRuntime rt = JavaManager.getAddJavaTask(binary).run().get();
} catch (UnsupportedPlatformException e) {
LOGGER.warning("Cannot add Java: " + e.getMessage());
// prompt user to choose a Java for the current OS/arch
} Prevention
- Always verify the binary's platform with JavaManager.isCompatible before adding
- Never copy JREs across machines of different OS/arch; download a native build
- Resolve symlinks and check the real target path before adding
- On ARM systems, explicitly avoid x86 builds unless running under a translation layer
When it happens
Trigger: Calling JavaManager.getAddJavaTask(binary) with a binary whose detected Platform differs from the current OS (e.g. platform.getOperatingSystem() != OperatingSystem.CURRENT_OS) or whose architecture is not supported on the current system (isCompatible returns false for non-current archs per the OS-specific switch).
Common situations: User manually points HMCL at a JRE copied from another machine/OS (Windows java.exe on Linux, x86 JRE on ARM, etc.); a portable Minecraft distribution moved across platforms; a misdetected Java binary inside a Wine/Proton prefix; symlinked binaries resolving to a foreign-arch runtime.
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
- Platform is mismatch: expected
- Failed to find current HMCL location
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/4c3795920db12ff9.
Report an issue: GitHub.
Appendix: source
Thrown at HMCL/src/main/java/org/jackhuang/hmcl/java/JavaManager.java:217
JavaInfo info = JavaInfoUtils.fromExecutable(executable);
return JavaRuntime.of(executable, info, false);
}
public static void refresh() {
Task.supplyAsync(() -> searchPotentialJavaExecutables(false)).whenComplete(Schedulers.javafx(), (result, exception) -> {
if (result != null) {
LATCH.await();
allJava = result;
updateAllJavaProperty(result);
}
}).start();
}
public static Task<JavaRuntime> getAddJavaTask(Path binary) {
return Task.supplyAsync("Get Java", () -> JavaManager.getJava(binary))
.thenApplyAsync(Schedulers.javafx(), javaRuntime -> {
if (!JavaManager.isCompatible(javaRuntime.getPlatform())) {
throw new UnsupportedPlatformException("Incompatible platform: " + javaRuntime.getPlatform());
}
String pathString = javaRuntime.getBinary().toString();
if (!SettingsManager.isUserSettingsReadOnly()) {
SettingsManager.userSettings().getDisabledJava().remove(pathString);
if (SettingsManager.userSettings().getUserJava().add(pathString)) {
addJava(javaRuntime);
}
}
return javaRuntime;
});
}
public static Task<JavaRuntime> getDownloadJavaTask(DownloadProvider downloadProvider, Platform platform, GameJavaVersion gameJavaVersion) {
return REPOSITORY.getDownloadJavaTask(downloadProvider, platform, gameJavaVersion)
.thenApplyAsync(Schedulers.javafx(), java -> {
addJava(java);View on GitHub (pinned to 24702dc5a0)