internal static IEnumerable <JdkInfo> GetVSAndroidJdks(Action <TraceLevel, string> logger) { if (!OS.IsWindows) { yield break; } var root = RegistryEx.LocalMachine; var wows = new[] { RegistryEx.Wow64.Key32, RegistryEx.Wow64.Key64 }; var subKey = @"SOFTWARE\Microsoft\VisualStudio\Android"; var valueName = "JavaHome"; foreach (var wow in wows) { if (!RegistryEx.CheckRegistryKeyForExecutable(root, subKey, valueName, wow, "bin", "java.exe")) { continue; } var path = RegistryEx.GetValueString(root, subKey, valueName, wow) ?? ""; if (string.IsNullOrEmpty(path)) { continue; } var jdk = JdkInfo.TryGetJdkInfo(path, logger, subKey); if (jdk == null) { continue; } yield return(jdk); } }
internal static string?GetWindowsPreferredJdkPath() { var wow = RegistryEx.Wow64.Key32; var regKey = AndroidSdkWindows.GetMDRegistryKey(); if (RegistryEx.CheckRegistryKeyForExecutable(RegistryEx.CurrentUser, regKey, AndroidSdkWindows.MDREG_JAVA_SDK, wow, "bin", "java.exe")) { return(RegistryEx.GetValueString(RegistryEx.CurrentUser, regKey, AndroidSdkWindows.MDREG_JAVA_SDK, wow)); } return(null); }
static IEnumerable <string> GetOracleJdkPaths() { string subkey = @"SOFTWARE\JavaSoft\Java Development Kit"; foreach (var wow64 in new[] { RegistryEx.Wow64.Key32, RegistryEx.Wow64.Key64 }) { string key_name = string.Format(@"{0}\{1}\{2}", "HKLM", subkey, "CurrentVersion"); var currentVersion = RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey, "CurrentVersion", wow64); if (!string.IsNullOrEmpty(currentVersion)) { if (RegistryEx.CheckRegistryKeyForExecutable(RegistryEx.LocalMachine, subkey + "\\" + "1.8", "JavaHome", wow64, "bin", "java.exe")) { yield return(RegistryEx.GetValueString(RegistryEx.LocalMachine, subkey + "\\" + "1.8", "JavaHome", wow64) ?? ""); } } } }