ITeye博客

程序判断java版本

zcmor · 2012-07-01 11:51 · java 基础 · 编程语言 · netty · java version · Markdown

下面是摘自netty的源码,由于判断运行的java 版本。

private static int javaVersion0() {
    try {
        // Check if its android, if so handle it the same way as java6.
        //
        // See https://github.com/netty/netty/issues/282
        Class.forName("android.app.Application");
        return 6;
    } catch (ClassNotFoundException e) {
        //Ignore
    }

    try {
        Deflater.class.getDeclaredField("SYNC_FLUSH");
        return 7;
    } catch (Exception e) {
        // Ignore
    }

    try {
        Double.class.getDeclaredField("MIN_NORMAL");
        return 6;
    } catch (Exception e) {
        // Ignore
    }

    return 5;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。