Snippet
The key here is to use the system property java.version and get minor and point version.
- publicclass CheckVersion {
- publicstaticvoid main(String[] args){
- String version =System.getProperty("java.version");
- char minor = version.charAt(2);
- char point = version.charAt(4);
- if(minor <'4'|| point <'1')
- thrownew RuntimeException("JDK 1.4.1 or higher "+
- "is required run this app");
- System.out.println("JDK version "+ version +" found");
- }