Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
namespace Xamarin.Android.Tools
{
public class JdkInfo {
static readonly string[] JdkLibraryTopDirs = {
"jre",
"lib",
};

public string HomePath {get;}

Expand Down Expand Up @@ -52,9 +56,23 @@ public JdkInfo (string homePath)
JarPath = ProcessUtils.FindExecutablesInDirectory (binPath, "jar").FirstOrDefault ();
JavaPath = ProcessUtils.FindExecutablesInDirectory (binPath, "java").FirstOrDefault ();
JavacPath = ProcessUtils.FindExecutablesInDirectory (binPath, "javac").FirstOrDefault ();

string topDir = null;
foreach (string dir in JdkLibraryTopDirs) {
topDir = Path.Combine (HomePath, dir);
if (!Directory.Exists (topDir)) {
topDir = null;
continue;
}
break;
}

if (String.IsNullOrEmpty (topDir))
topDir = Path.Combine (HomePath, JdkLibraryTopDirs [0]);

JdkJvmPath = OS.IsMac
? FindLibrariesInDirectory (Path.Combine (HomePath, "jre"), "jli").FirstOrDefault ()
: FindLibrariesInDirectory (Path.Combine (HomePath, "jre"), "jvm").FirstOrDefault ();
? FindLibrariesInDirectory (topDir, "jli").FirstOrDefault ()
: FindLibrariesInDirectory (topDir, "jvm").FirstOrDefault ();

ValidateFile ("jar", JarPath);
ValidateFile ("java", JavaPath);
Expand Down