Added error dialog when launching with 32-bit windows or Java 8

This commit is contained in:
Anuken 2026-02-15 12:49:28 -05:00
parent f6266db2bc
commit b1d40fb039
2 changed files with 65 additions and 0 deletions

View file

@ -45,6 +45,10 @@ public class DesktopLauncher extends ClientLauncher{
try{
Vars.loadLogger();
check32Bit();
checkJavaVersion();
new SdlApplication(new DesktopLauncher(arg), new SdlConfig(){{
title = "Mindustry";
maximized = true;
@ -111,6 +115,42 @@ public class DesktopLauncher extends ClientLauncher{
}
}
static void checkJavaVersion(){
if(OS.javaVersionNumber < 17){
//this is technically a lie: Java 25 isn't actually required (17 is), but I want people to get the highest available version they can.
//Java 25 *might* be required in the future for FFM bindings.
ErrorDialog.show("Java 25 is required to run Mindustry. Your version: " + OS.javaVersionNumber + "\n" +
"\n" +
"Please uninstall your current Java version, and download Java 25.\n" +
"\n" +
"It is recommended to download Java from adoptium.net.\n" +
"Do not download from java.com, as that will give you Java 8 by default.");
}
}
static void check32Bit(){
if(OS.isWindows && !OS.is64Bit){
try{
Version.init();
}catch(Throwable ignored){
}
boolean steam = Version.modifier != null && Version.modifier.contains("steam");
String versionWarning = "";
if(steam){
versionWarning = "\n\nIf you are unable to upgrade, consider switching to the legacy v7 branch on Steam, which is the last release that supported 32-bit windows:\n(properties -> betas -> select version-7.0 in the drop-down box).";
}else if(OS.javaVersion.equals("1.8.0_151-1-ojdkbuild")){ //version string of JVM packaged with the 32-bit version of the game on itch/steam
versionWarning = "\n\nMake sure you have downloaded the 64-bit version of the game, not the 32-bit one.";
}else if(OS.javaVersionNumber < 25){
//technically, java 25 isn't required yet, but it might be in the future, so tell users to get that one
versionWarning = "\n\nYour current Java version is: " + OS.javaVersionNumber + ". To run the game, upgrade to Java 25 on a 64-bit machine.";
}
ErrorDialog.show("You are running a 32-bit installation of Windows and/or a 32-bit JVM. 32-bit windows is no longer supported." + versionWarning);
}
}
public DesktopLauncher(String[] args){
this.args = args;

View file

@ -0,0 +1,25 @@
package mindustry.desktop;
import arc.util.*;
import org.lwjgl.sdl.*;
import javax.swing.*;
//placed in a separate class due to the javawx.swing dependency, which is not present in the bundled JVM
public class ErrorDialog{
public static void show(String text){
Log.err(text);
try{
//will fail in the future on 32-bit platforms as no natives will be loaded
SDLMessageBox.SDL_ShowSimpleMessageBox(SDLMessageBox.SDL_MESSAGEBOX_ERROR, "it's over", text, 0);
}catch(Throwable error){
try{
//usually won't work on packaged JVMs, but I won't be distributing those with 32 bit windows anyway
JOptionPane.showMessageDialog(null, text);
}catch(Throwable ignored){
}
}
System.exit(1);
}
}