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

org.noear.nami.common.JavaUtils Maven / Gradle / Ivy

There is a newer version: 3.0.0-M4
Show newest version
package org.noear.nami.common;

import java.io.File;

/**
 * Java 工具类(获取版本信息)
 *
 * @author noear
 * @since 1.10
 */
public class JavaUtils {
    /**
     * Java 版本号
     * */
    public static final int JAVA_MAJOR_VERSION;

    /**
     * 是否为 Windows
     */
    public static final boolean IS_WINDOWS = (File.separatorChar == '\\');

    /*
     * 获取 Java 版本号
     * http://openjdk.java.net/jeps/223
     * 1.8.x  = 8
     * 11.x   = 11
     * 17.x   = 17
     */
    static {
        int majorVersion;
        try {
            String version = System.getProperty("java.specification.version");
            if (version.startsWith("1.")) {
                version = version.substring(2);
            }
            majorVersion = Integer.parseInt(version);
        } catch (Throwable ignored) {
            majorVersion = 8;
        }
        JAVA_MAJOR_VERSION = majorVersion;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy