How to check JRE version prior to launch?

前端 未结 13 2274
天命终不由人
天命终不由人 2020-12-01 11:08

What\'s the best way to determine if the version of the JRE installed on a machine is high enough for the application which the user wants to run? Is there a way of doing it

13条回答
  •  天命终不由人
    2020-12-01 12:04

    For the launcher - Check the version in there.

    Inside the APP; as above use System.getProperties();

    Properties sProp = java.lang.System.getProperties();
    String sVersion = sProp.getProperty("java.version");
    sVersion = sVersion.substring(0, 3);
    Float f = Float.valueOf(sVersion);
    if (f.floatValue() < (float) 1.4) {
        System.out.println("Java version too low ....");
        System.exit(1);
    }
    ...
    

提交回复
热议问题