Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

How to progamatically Java version?

$
0
0

Snippet

The key here is to use the system property java.version and get minor and point version.

  1. publicclass CheckVersion {
  2.   publicstaticvoid main(String[] args){
  3.     String version =System.getProperty("java.version");
  4.     char minor = version.charAt(2);
  5.     char point = version.charAt(4);
  6.     if(minor <'4'|| point <'1')
  7.       thrownew RuntimeException("JDK 1.4.1 or higher "+
  8.         "is required run this app");
  9.     System.out.println("JDK version "+ version +" found");
  10.   }

Viewing all articles
Browse latest Browse all 178

Trending Articles