1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jdiagnose.library;
17
18 import org.jdiagnose.DiagnosticUnit;
19 import org.jdiagnose.DiagnosticException;
20
21 /***
22 * JDiagnose Diagnosic. Just checks the Java Version for now.
23 * User: jamie
24 * Date: May 31, 2004
25 * Time: 8:42:47 PM
26 */
27 public class DiagnoseDiagnostic extends DiagnosticUnit {
28
29 /***
30 * Default Constructor
31 */
32 public DiagnoseDiagnostic() {
33 super();
34 }
35
36 /***
37 * Construct with a new fully qualified name
38 * @param name the fqn of this diagnostic
39 */
40 public DiagnoseDiagnostic(String name) {
41 super(name);
42 }
43
44 /***
45 * Check to see that the Java Version is 1.3 or higher
46 * @throws DiagnosticException if the Java Version isn't matched
47 */
48 public void diagnoseJavaVersion13OrGreater() throws DiagnosticException {
49 String javaClassVersion = System.getProperty("java.class.version");
50 assertNotNull("System property java.class.version should not be null", javaClassVersion);
51 try {
52 double version = Double.parseDouble(javaClassVersion);
53 assertTrue("Your Java version should be 1.3 or above", version >= 47.0);
54 } catch (NumberFormatException e) {
55 throw new DiagnosticException("System property java.class.version " +
56 "should be a number but is " + javaClassVersion);
57 }
58 }
59
60 }