Check Version : System Properties « Development Class « Java






Check Version

  

//: com:bruceeckel:tools:CheckVersion.java
// {RunByHand}
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

public class CheckVersion {
  public static void main(String[] args) {
    String version = System.getProperty("java.version");
    char minor = version.charAt(2);
    char point = version.charAt(4);
    if(minor < '4' || point < '1')
      throw new RuntimeException("JDK 1.4.1 or higher " +
        "is required to run the examples in this book.");
    System.out.println("JDK version "+ version + " found");
  }
} ///:~


           
         
    
  








Related examples in the same category

1.Get system properties using System class
2.Get Java specification version using System class
3.Display System PropertiesDisplay System Properties
4.Use System.getenv to get environment variables
5.Machine User NameMachine User Name
6.Get username of system current user
7.Get Java Runtime Environment (JRE) version?
8.Clear system property: The System.clearProperty() method available in Java 1.5
9.Dealing with the Java environment
10.Get operating system temporary directory / folder
11.List one or more item(s) from System Properties
12.System.setProperty("apple.laf.useScreenMenuBar", "true")
13.Get Java Home directory
14.Determine operating system using System class
15.Setting the Value of a System Property from the Command Line: add -D option to the java command when running your program.
16.Get path / classpath separator
17.Get file separator symbol
18.Get operating system name and version
19.Get user home directory name
20.Set a system property
21.Dump PropsDump Props
22.Get Environment Variables
23.This program prints out all system properties