Java Code Examples for org.gradle.internal.jvm.Jvm#current()

The following examples show how to use org.gradle.internal.jvm.Jvm#current() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AvailableJavaHomes.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Locates a JDK installation that is different to the current JVM, ie for which java.home is different.
 *
 * @return null if not found.
 */
@Nullable
public static JavaInfo getDifferentJdk() {
    Jvm jvm = Jvm.current();
    for (JvmInstallation candidate : getJvms()) {
        if (candidate.getJavaHome().equals(jvm.getJavaHome())) {
            continue;
        }

        // Currently tests implicitly assume a JDK
        if (!candidate.isJdk()) {
            continue;
        }
        return Jvm.forHome(candidate.getJavaHome());
    }

    return null;
}
 
Example 2
Source File: AvailableJavaHomes.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Locates a JDK 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;
        }
        // Currently tests implicitly assume a JDK
        if (!candidate.isJdk()) {
            continue;
        }
        return Jvm.forHome(candidate.getJavaHome());
    }

    return null;
}
 
Example 3
Source File: AvailableJavaHomes.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Locates a JDK installation that is different to the current JVM, ie for which java.home is different.
 *
 * @return null if not found.
 */
@Nullable
public static JavaInfo getDifferentJdk() {
    Jvm jvm = Jvm.current();
    for (JvmInstallation candidate : getJvms()) {
        if (candidate.getJavaHome().equals(jvm.getJavaHome())) {
            continue;
        }

        // Currently tests implicitly assume a JDK
        if (!candidate.isJdk()) {
            continue;
        }
        return Jvm.forHome(candidate.getJavaHome());
    }

    return null;
}
 
Example 4
Source File: AvailableJavaHomes.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Locates a JDK 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;
        }
        // Currently tests implicitly assume a JDK
        if (!candidate.isJdk()) {
            continue;
        }
        return Jvm.forHome(candidate.getJavaHome());
    }

    return null;
}
 
Example 5
Source File: AvailableJavaHomes.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Locates a JRE installation for the current JVM. Prefers a stand-alone JRE installation over one that is part of a JDK install.
 *
 * @return The JRE home directory, or null if not found
 */
public static File getBestJre() {
    Jvm jvm = Jvm.current();
    Jre jre = jvm.getStandaloneJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    jre = jvm.getJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    return null;
}
 
Example 6
Source File: AvailableJavaHomes.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Locates a JRE installation for the current JVM. Prefers a stand-alone JRE installation over one that is part of a JDK install.
 *
 * @return The JRE home directory, or null if not found
 */
public static File getBestJre() {
    Jvm jvm = Jvm.current();
    Jre jre = jvm.getStandaloneJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    jre = jvm.getJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    return null;
}
 
Example 7
Source File: AvailableJavaHomes.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Locates a JRE installation for the current JVM. Prefers a stand-alone JRE installation over one that is part of a JDK install.
 *
 * @return The JRE home directory, or null if not found
 */
public static File getBestJre() {
    Jvm jvm = Jvm.current();
    Jre jre = jvm.getStandaloneJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    jre = jvm.getJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    return null;
}
 
Example 8
Source File: AvailableJavaHomes.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Locates a JRE installation for the current JVM. Prefers a stand-alone JRE installation over one that is part of a JDK install.
 *
 * @return The JRE home directory, or null if not found
 */
public static File getBestJre() {
    Jvm jvm = Jvm.current();
    Jre jre = jvm.getStandaloneJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    jre = jvm.getJre();
    if (jre != null) {
        return jre.getHomeDir();
    }
    return null;
}
 
Example 9
Source File: NativeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Jvm createJvm() {
    return Jvm.current();
}
 
Example 10
Source File: DefaultJavaForkOptions.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaForkOptions(FileResolver resolver) {
    this(resolver, Jvm.current());
}
 
Example 11
Source File: NativeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Jvm createJvm() {
    return Jvm.current();
}
 
Example 12
Source File: DefaultJavaForkOptions.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaForkOptions(FileResolver resolver) {
    this(resolver, Jvm.current());
}
 
Example 13
Source File: NativeServices.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Jvm createJvm() {
    return Jvm.current();
}
 
Example 14
Source File: DefaultJavaForkOptions.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaForkOptions(FileResolver resolver) {
    this(resolver, Jvm.current());
}
 
Example 15
Source File: NativeServices.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Jvm createJvm() {
    return Jvm.current();
}
 
Example 16
Source File: DefaultJavaForkOptions.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaForkOptions(FileResolver resolver) {
    this(resolver, Jvm.current());
}