All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.util.SystemUtil Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.util;

public class SystemUtil {

    public static boolean isWindows() {
        return StringUtil.trimToEmpty(System.getProperties().getProperty("os.name")).toLowerCase().startsWith("windows");
    }

    /**
     * Returns java.version system property
     */
    public static String getJavaVersion() {
        return System.getProperty("java.version");
    }


    /**
     * Returns the "major" version of java, including returning "8" for java "1.8"
     */
    public static int getJavaMajorVersion() {
        final String version = getJavaVersion();
        String[] splitVersion = version.split("\\.", 2);
        int majorVersion = Integer.parseInt(splitVersion[0]);
        if (majorVersion == 1) {
            splitVersion = splitVersion[1].split("\\.", 2);
            return Integer.parseInt(splitVersion[0]);
        }
        return majorVersion;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy