Last change
on this file since 13316 was 10757, checked in by mdewsnip, 19 years ago |
Source code for CheckJavaVersion.class: looks at the Java version and returns 2 if >= 1.4.0 (ie. suitable for running the GLI), 1 otherwise.
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.1 KB
|
Line | |
---|
1 | public class CheckJavaVersion
|
---|
2 | {
|
---|
3 | static public void main(String[] args)
|
---|
4 | {
|
---|
5 | String java_version = System.getProperty("java.version");
|
---|
6 | System.out.println("Java version: " + java_version);
|
---|
7 |
|
---|
8 | try {
|
---|
9 | // Identify major version number
|
---|
10 | int major_dot_position = java_version.indexOf(".");
|
---|
11 | String java_version_major_string = java_version.substring(0, major_dot_position);
|
---|
12 | int java_version_major = (new Integer(java_version_major_string)).intValue();
|
---|
13 |
|
---|
14 | // Identify minor version number
|
---|
15 | int minor_dot_position = java_version.indexOf(".", major_dot_position + 1);
|
---|
16 | String java_version_minor_string = java_version.substring(major_dot_position + 1, minor_dot_position);
|
---|
17 | int java_version_minor = (new Integer(java_version_minor_string)).intValue();
|
---|
18 |
|
---|
19 | // Version of Java must be 1.4 or higher to run the GLI
|
---|
20 | if (java_version_major > 1 || (java_version_major == 1 && java_version_minor >= 4)) {
|
---|
21 | // Valid
|
---|
22 | System.exit(2);
|
---|
23 | }
|
---|
24 | else {
|
---|
25 | // Invalid
|
---|
26 | System.exit(1);
|
---|
27 | }
|
---|
28 | }
|
---|
29 | catch (Exception exception) {
|
---|
30 | System.err.println("Exception: " + exception);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.