Tests whether or not the current VM is a Java 6 or higher VM. - Java Java Virtual Machine

Java examples for Java Virtual Machine:Version

Description

Tests whether or not the current VM is a Java 6 or higher VM.

Demo Code

/*-//from ww  w .  j a va 2  s  .  c o  m
 * Copyright (C) 2008 Erik Larsson
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
//package com.java2s;

public class Main {
    /**
     * Tests whether or not the current VM is a Java 6 or higher VM. This method
     * should always be invoked to check that the version number of the
     * currently running JRE is higher than or equal to 1.6 before invoking any
     * of the methods in Java6Specific.
     * 
     * @return whether or not the current VM is a Java 6 or higher VM.
     */
    public static boolean isJava6OrHigher() {
        return System.getProperty("java.specification.version").compareTo(
                "1.6") >= 0;
    }
}

Related Tutorials