- Timestamp:
- 2008-04-30T16:42:33+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/trunk/gs3-webservices-democlient/CheckJavaVersion.java
r15232 r15307 11 11 * mentioned. If arg[0] is left out as well, then Greenstone3's 12 12 * minimum default version of 1.4.x is assumed. 13 * The program exits with -1 if the Java version being used is14 * incompatible and with 0if 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. 15 15 */ 16 16 public static void main(String[] args) { … … 51 51 boolean acceptable = true; 52 52 // 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++) 54 55 { 55 56 int min = Integer.parseInt(minVersionNums[i]); … … 63 64 } 64 65 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 65 83 if(acceptable) { 66 84 System.out.println("Found compatible Java version " +runningJavaVersion); 67 System.exit( 0); // acceptable case85 System.exit(2); // acceptable case 68 86 } else { 69 87 System.out.println("The current Java version " + 70 88 runningJavaVersion + " is insufficient to run " + programName); 71 System.exit( -1);89 System.exit(1); 72 90 } 73 91 }
Note:
See TracChangeset
for help on using the changeset viewer.