From 535f82514e38261688a15f1564638d6957129cc7 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 16 Jan 2026 20:31:10 +0800 Subject: fix: improve Java path normalization logic Enhanced the normalization logic for Java paths by ensuring that the search for "java.exe" in the PATH only occurs for relative paths or the name "java", excluding absolute paths that do not exist. This change improves the reliability of locating the Java executable in various environments. --- src-tauri/src/utils/path.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/utils/path.rs b/src-tauri/src/utils/path.rs index 1db6e5b..ab14c12 100644 --- a/src-tauri/src/utils/path.rs +++ b/src-tauri/src/utils/path.rs @@ -48,8 +48,12 @@ pub fn normalize_java_path(java_path: &str) -> Result { path.set_extension("exe"); } - // If still not found and it's just "java.exe", try to find it in PATH - if !path.exists() && path.file_name() == Some(std::ffi::OsStr::new("java.exe")) { + // If still not found and it's just "java.exe" (not an absolute path), try to find it in PATH + // Only search PATH for relative paths or just "java", not for absolute paths that don't exist + if !path.exists() + && !path.is_absolute() + && path.file_name() == Some(std::ffi::OsStr::new("java.exe")) + { // Try to locate java.exe in PATH if let Ok(output) = std::process::Command::new("where").arg("java").output() { if output.status.success() { -- cgit v1.2.3-70-g09d2