Example #1
0
 public static string FindPath(JavaVMConfiguration configuration)
 {
     int strategyCount = configuration.DiscoveryStrategyCount;
     for (int i = 0; i < strategyCount; i++)
     {
         JavaVMDiscoveryStrategy strategy = configuration.GetDiscoveryStrategyAtIndex(i);
         JavaVMDiscoveryType discoveryType = strategy.DiscoveryType;
         string discoverySpec = strategy.Specification;
         string workingSpec = discoverySpec == null ? string.Empty : discoverySpec;
         ReadOnlyCollection<String> hints = strategy.Hints;
         workingSpec = workingSpec.Trim();
         string outputPath = null;
         if (discoveryType == JavaVMDiscoveryType.Path)
         {
             outputPath = PlatformFactory.Platform.FindJvmLibraryWithPath(workingSpec);
         }
         else if (discoveryType == JavaVMDiscoveryType.Lookup)
         {
             outputPath = PlatformFactory.Platform.LookupJvmLibrary(workingSpec);
         }
         if (outputPath != null)
         {
             return outputPath;
         }
     }
     throw new JniException("Failed to find JVM Path.");
 }