diff options
| author | 2026-01-16 20:31:10 +0800 | |
|---|---|---|
| committer | 2026-01-16 20:31:10 +0800 | |
| commit | 535f82514e38261688a15f1564638d6957129cc7 (patch) | |
| tree | 943294b9262df53432ae6847622a6b86a6a2471c /src-tauri | |
| parent | 853f40dc13e6463bedf30e2471a71bd011be425b (diff) | |
| download | DropOut-535f82514e38261688a15f1564638d6957129cc7.tar.gz DropOut-535f82514e38261688a15f1564638d6957129cc7.zip | |
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.
Diffstat (limited to 'src-tauri')
| -rw-r--r-- | src-tauri/src/utils/path.rs | 8 |
1 files 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<PathBuf, String> { 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() { |