01: /*
02: * WbStarter.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench;
13:
14: import java.lang.reflect.Method;
15:
16: import javax.swing.JOptionPane;
17:
18: /**
19: * This is a wrapper to kick-off the actual WbManager class. It should run
20: * with any JDK >= 1.3 as it does no reference any other classes.
21: * This class is compiled separately in build.xml to allow for a different
22: * class file version between this class and the rest of the application.
23: * Thus a check for the correct JDK version can be done inside the Java code.
24: *
25: * @author support@sql-workbench.net
26: */
27: public class WbStarter {
28:
29: /**
30: * @param args the command line arguments
31: */
32: public static void main(String[] args) {
33: // This property should be set as early as possible to
34: // ensure that it is defined before any AWT class is loaded
35: // this will make the application menu appear at the correct
36: // location when running on with Aqua look and feel on a Mac
37: System.setProperty("apple.laf.useScreenMenuBar", "true");
38: System.setProperty(
39: "com.apple.mrj.application.growbox.intrudes", "false");
40: System.setProperty("apple.awt.showGrowBox", "true");
41: System.setProperty("apple.awt.rendering", "speed");
42:
43: String version = System.getProperty("java.version", null);
44: if (version == null) {
45: version = System.getProperty("java.runtime.version");
46: }
47:
48: boolean versionIsOk = false;
49: final int minMinorVersion = 5;
50:
51: int minorversion = -1;
52:
53: try {
54: int majorversion = Integer
55: .parseInt(version.substring(0, 1));
56: minorversion = Integer.parseInt(version.substring(2, 3));
57: versionIsOk = (majorversion >= 1)
58: && (minorversion >= minMinorVersion);
59: } catch (Exception e) {
60: versionIsOk = false;
61: }
62:
63: if (!versionIsOk) {
64: String error = "A JVM version 1."
65: + minMinorVersion
66: + " or higher is needed to run SQL Workbench/J (Found: "
67: + version + ")";
68: System.err.println("*** Cannot run this application ***");
69: System.err.println(error);
70: try {
71: JOptionPane.showMessageDialog(null, error);
72: } catch (Throwable e) {
73: // Ignore
74: }
75: System.exit(1);
76: }
77:
78: try {
79: // Do not reference WbManager directly, otherwise a compile
80: // of this class will trigger a compile of the other classes, but they
81: // should be compiled with a different class file version (see build.xml)
82: Class mgr = Class.forName("workbench.WbManager");
83: Method main = mgr.getDeclaredMethod("main",
84: new Class[] { String[].class });
85: main.invoke(null, new Object[] { args });
86: } catch (Throwable e) {
87: e.printStackTrace();
88: }
89:
90: }
91:
92: }
|