1 19 20 package edu.umd.cs.findbugs; 21 22 import java.awt.GraphicsEnvironment ; 23 import java.io.IOException ; 24 import java.lang.reflect.Method ; 25 26 30 public class LaunchAppropriateUI { 31 public static void main(String args[]) throws Exception { 32 int launchProperty = getLaunchProperty(); 33 if (GraphicsEnvironment.isHeadless() || launchProperty == 0) 34 FindBugs2.main(args); 35 else { 36 String version = System.getProperty("java.version"); 37 38 Class launchClass = null; 39 if ("1.5".compareTo(version) <= 0) try { 40 launchClass = Class.forName("edu.umd.cs.findbugs.gui2.Driver", false, 41 LaunchAppropriateUI.class.getClassLoader()); 42 } catch (ClassNotFoundException e) { 43 assert true; 44 } 45 if (launchClass == null || launchProperty == 1) 46 launchClass = edu.umd.cs.findbugs.gui.FindBugsFrame.class; 47 48 Method mainMethod = launchClass.getMethod("main", args.getClass()); 49 mainMethod.invoke(null, (Object ) args); 50 } 51 } 52 53 61 public static int getLaunchProperty() { 62 String s = System.getProperty("findbugs.launchUI", "2"); 63 try { 64 return Integer.parseInt(s); 65 } catch (NumberFormatException nfe) { 66 return 2; 67 } 68 } 69 70 } 71 | Popular Tags |