diff --git a/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs b/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs index d73b748b..9ec28ed2 100644 --- a/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs +++ b/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs @@ -200,6 +200,23 @@ Dictionary> GetJavaProperties () return GetJavaProperties (ProcessUtils.FindExecutablesInDirectory (Path.Combine (HomePath, "bin"), "java").First ()); } + static bool AnySystemJavasInstalled () + { + if (OS.IsMac) { + string path = Path.Combine (Path.DirectorySeparatorChar + "System", "Library", "Java", "JavaVirtualMachines"); + if (!Directory.Exists (path)) { + return false; + } + + string[] dirs = Directory.GetDirectories (path); + if (dirs == null || dirs.Length == 0) { + return false; + } + } + + return true; + } + static Dictionary> GetJavaProperties (string java) { var javaProps = new ProcessStartInfo { @@ -209,6 +226,10 @@ static Dictionary> GetJavaProperties (string java) var props = new Dictionary> (); string curKey = null; + + if (!AnySystemJavasInstalled () && (java == "/usr/bin/java" || java == "java")) + return props; + ProcessUtils.Exec (javaProps, (o, e) => { const string ContinuedValuePrefix = " "; const string NewValuePrefix = " ";