Fix Java 8 resolution for MfApi restart, refresh targets after settings, and copy errors to clipboard.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -356,84 +356,35 @@ public sealed class SonicMfApiExecutor
|
||||
|
||||
private string? ResolveJavaExe()
|
||||
{
|
||||
foreach (string? candidate
|
||||
in EnumerateJavaCandidates())
|
||||
// Explizite Verbindungs-Pfade zuerst, dann Java-8-Suche
|
||||
// (Runtime\bin\java.exe fehlt oft; JAVA_HOME zeigt oft auf JDK 21).
|
||||
string? fromConnection = JavaRuntimeLocator.Resolve(
|
||||
!string.IsNullOrWhiteSpace(_connection.JavaPath)
|
||||
? _connection.JavaPath
|
||||
: null);
|
||||
|
||||
if (fromConnection is not null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(candidate))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string resolvedCandidate;
|
||||
|
||||
try
|
||||
{
|
||||
resolvedCandidate =
|
||||
Path.IsPathRooted(candidate)
|
||||
? Path.GetFullPath(candidate)
|
||||
: Path.GetFullPath(
|
||||
Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
candidate));
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (File.Exists(resolvedCandidate))
|
||||
{
|
||||
return resolvedCandidate;
|
||||
}
|
||||
return fromConnection;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IEnumerable<string?>
|
||||
EnumerateJavaCandidates()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(
|
||||
_connection.JavaPath))
|
||||
if (!string.IsNullOrWhiteSpace(_connection.JavaHome))
|
||||
{
|
||||
yield return
|
||||
_connection.JavaPath.Trim();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(
|
||||
_connection.JavaHome))
|
||||
{
|
||||
yield return Path.Combine(
|
||||
string fromHome = Path.Combine(
|
||||
_connection.JavaHome.Trim(),
|
||||
"bin",
|
||||
"java.exe");
|
||||
|
||||
string? resolvedHome =
|
||||
JavaRuntimeLocator.Resolve(fromHome);
|
||||
|
||||
if (resolvedHome is not null)
|
||||
{
|
||||
return resolvedHome;
|
||||
}
|
||||
}
|
||||
|
||||
string? javaHome =
|
||||
Environment.GetEnvironmentVariable(
|
||||
"JAVA_HOME");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(javaHome))
|
||||
{
|
||||
yield return Path.Combine(
|
||||
javaHome.Trim(),
|
||||
"bin",
|
||||
"java.exe");
|
||||
}
|
||||
|
||||
string? jreHome =
|
||||
Environment.GetEnvironmentVariable(
|
||||
"JRE_HOME");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(jreHome))
|
||||
{
|
||||
yield return Path.Combine(
|
||||
jreHome.Trim(),
|
||||
"bin",
|
||||
"java.exe");
|
||||
}
|
||||
|
||||
yield return "java.exe";
|
||||
return JavaRuntimeLocator.Resolve();
|
||||
}
|
||||
|
||||
private (
|
||||
|
||||
Reference in New Issue
Block a user