Exemplo n.º 1
0
 /**
  * Locates a JDK installation for the given version.
  *
  * @return null if not found.
  */
 @Nullable
 public static JavaInfo getJdk(JavaVersion version) {
   for (JvmInstallation candidate : getJvms()) {
     if (candidate.getJavaVersion().equals(version) && candidate.isJdk()) {
       return Jvm.forHome(candidate.getJavaHome());
     }
   }
   return null;
 }
Exemplo n.º 2
0
  /**
   * Locates a JVM installation that has a different version to the current JVM, ie for which
   * java.version is different.
   *
   * @return null if not found.
   */
  @Nullable
  public static JavaInfo getDifferentVersion() {
    Jvm jvm = Jvm.current();
    for (JvmInstallation candidate : getJvms()) {
      if (candidate.getJavaVersion().equals(jvm.getJavaVersion())) {
        continue;
      }
      return Jvm.forHome(candidate.getJavaHome());
    }

    return null;
  }