Example usage for org.apache.commons.lang SystemUtils JAVA_VERSION

List of usage examples for org.apache.commons.lang SystemUtils JAVA_VERSION

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils JAVA_VERSION.

Prototype

String JAVA_VERSION

To view the source code for org.apache.commons.lang SystemUtils JAVA_VERSION.

Click Source Link

Document

The java.version System Property.

Usage

From source file:phex.Main.java

/**
 * /*from   w w  w .j  ava2 s. c  o m*/
 */
private static void validateJavaVersion() {
    if (SystemUtils.isJavaVersionAtLeast(1.5f)) {
        return;
    }

    JFrame frame = new JFrame("Wrong Java Version");
    frame.setSize(new Dimension(0, 0));
    frame.setVisible(true);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension winSize = frame.getSize();
    Rectangle rect = new Rectangle((screenSize.width - winSize.width) / 2,
            (screenSize.height - winSize.height) / 2, winSize.width, winSize.height);
    frame.setBounds(rect);
    JOptionPane.showMessageDialog(frame,
            "Please use a newer Java VM.\n" + "Phex requires at least Java 1.5.0. You are using Java "
                    + SystemUtils.JAVA_VERSION + "\n" + "To get the latest Java release go to http://java.com.",
            "Wrong Java Version", JOptionPane.WARNING_MESSAGE);
    System.exit(1);
}