diff options
| author | 2026-01-16 18:08:13 +0800 | |
|---|---|---|
| committer | 2026-01-16 18:08:13 +0800 | |
| commit | 52cf610264444bde95c1feae58414bb9849855eb (patch) | |
| tree | f207af68571b9958445da768a9135cbd1fa30e99 /src-tauri/src/main.rs | |
| parent | 4c34810b1d943f4d51af4a129066bcf928d31c29 (diff) | |
| parent | e38f3b0ac1277f3b918ceb5a819f98d598b1a419 (diff) | |
| download | DropOut-52cf610264444bde95c1feae58414bb9849855eb.tar.gz DropOut-52cf610264444bde95c1feae58414bb9849855eb.zip | |
Merge pull request #53 from BegoniaHe/fix/windows-java-path
Diffstat (limited to 'src-tauri/src/main.rs')
| -rw-r--r-- | src-tauri/src/main.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5ccbe96..463bd5d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -526,12 +526,28 @@ async fn start_game( emit_log!(window, format!("Java Args: {:?}", &args)); } + // Get Java path from config or detect + let java_path_str = if !config.java_path.is_empty() && config.java_path != "java" { + config.java_path.clone() + } else { + // Try to find a suitable Java installation + let javas = core::java::detect_all_java_installations(&app_handle); + if let Some(java) = javas.first() { + java.path.clone() + } else { + return Err( + "No Java installation found. Please configure Java in settings.".to_string(), + ); + } + }; + let java_path = utils::path::normalize_java_path(&java_path_str)?; + // Spawn the process emit_log!( window, - format!("Starting Java process: {}", config.java_path) + format!("Starting Java process: {}", java_path.display()) ); - let mut command = Command::new(&config.java_path); + let mut command = Command::new(&java_path); command.args(&args); command.current_dir(&game_dir); // Run in game directory command.stdout(Stdio::piped()); @@ -551,7 +567,7 @@ async fn start_game( // Spawn and handle output let mut child = command .spawn() - .map_err(|e| format!("Failed to launch java: {}", e))?; + .map_err(|e| format!("Failed to launch Java at '{}': {}\nPlease check your Java installation and path configuration in Settings.", java_path.display(), e))?; emit_log!(window, "Java process started successfully".to_string()); @@ -1540,7 +1556,7 @@ async fn install_forge( ); } }; - let java_path = std::path::PathBuf::from(&java_path_str); + let java_path = utils::path::normalize_java_path(&java_path_str)?; emit_log!(window, "Running Forge installer...".to_string()); |