Ignore:
Timestamp:
2008-04-30T16:42:33+12:00 (16 years ago)
Author:
ak19
Message:

Improved to deal with the case of minimum JavaVersion = 1.5.0_10_12 and 1.5.0_9_12 when running Java version = 1.5.0_10. In the first case it should not be acceptable and in the last it should be.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/trunk/gs3-webservices-democlient/CheckJavaVersion.java

    r15232 r15307  
    1111     * mentioned. If arg[0] is left out as well, then Greenstone3's
    1212     * minimum default version of 1.4.x is assumed.
    13      * The program exits with -1 if the Java version being used is
    14      * incompatible and with 0 if it is acceptable.
     13     * The program exits with 1 if the Java version being used is
     14     * incompatible and with 2 if it is acceptable.
    1515     */
    1616    public static void main(String[] args) {
     
    5151        boolean acceptable = true;
    5252        // only keep looping while we haven't gone past the end of either array
    53         for(int i=0; i < minVersionNums.length && i < runningVersionNums.length; i++)
     53        int i=0;
     54        for(; i < minVersionNums.length && i < runningVersionNums.length; i++)
    5455        {
    5556            int min = Integer.parseInt(minVersionNums[i]);
     
    6364        }
    6465       
     66        // Consider minVersion = 1.5.0_10 and runningVersion = 1.5.0
     67        // this means the runningversion is still insufficient.
     68        // HOWEVER, minVersion being longer does not always mean it is
     69        // a later version, consider: min=1.5.0_9.12 and run=1.5.0_10
     70        // This should be acceptable since 10 > 9 even though min is longer.
     71        // SOLUTION: If the last values for both were the same, the running
     72        // Version is not compatible if the minVersionNums array is longer
     73        int min = Integer.parseInt(minVersionNums[i-1]);
     74        int run = Integer.parseInt(runningVersionNums[i-1]);
     75       
     76        // if the last values were the same, check whether min is longer
     77        // in which case the running version is not acceptable
     78        if(min == run && minVersionNums.length > runningVersionNums.length)
     79        {
     80            acceptable = false;
     81        }
     82       
    6583        if(acceptable) {
    6684            System.out.println("Found compatible Java version " +runningJavaVersion);
    67             System.exit(0); // acceptable case
     85            System.exit(2); // acceptable case
    6886        } else {
    6987            System.out.println("The current Java version " +
    7088                runningJavaVersion + " is insufficient to run " + programName);
    71             System.exit(-1);
     89            System.exit(1);
    7290        }
    7391    }
Note: See TracChangeset for help on using the changeset viewer.