1 19 20 package com.izforge.izpack.uninstaller; 21 22 import javax.swing.*; 23 import java.lang.reflect.Method ; 24 25 30 public class Uninstaller 31 { 32 33 38 public static void main(String [] args) 39 { 40 boolean cmduninstall = false; 41 for (int q = 0; q < args.length; q++) if (args[q].equals("-c")) cmduninstall = true; 42 if (cmduninstall) System.out.println("Command line uninstaller.\n"); 43 try 44 { 45 Class clazz = Uninstaller.class; 46 Method target; 47 if (cmduninstall) 48 target = clazz.getMethod("cmduninstall", new Class []{String [].class}); 49 else 50 target = clazz.getMethod("uninstall", new Class []{String [].class}); 51 new SelfModifier(target).invoke(args); 52 } 53 catch (Exception ioeOrTypo) 54 { 55 System.err.println(ioeOrTypo.getMessage()); 56 ioeOrTypo.printStackTrace(); 57 System.err.println("Unable to exec java as a subprocess."); 58 System.err.println("The uninstall may not fully complete."); 59 uninstall(args); 60 } 61 } 62 63 public static void cmduninstall(String [] args) 64 { 65 try 66 { 67 UninstallerConsole uco = new UninstallerConsole(); 68 boolean force = false; 69 for (int q = 0; q < args.length; q++) if (args[q].equals("-f")) force = true; 70 System.out.println("Force deletion: " + force); 71 uco.runUninstall(force); 72 } 73 catch (Exception err) 74 { 75 System.err.println("- Error -"); 76 err.printStackTrace(); 77 System.exit(0); 78 } 79 } 80 81 public static void uninstall(String [] args) 82 { 83 SwingUtilities.invokeLater(new Runnable () 84 { 85 public void run() 86 { 87 try 88 { 89 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 90 new UninstallerFrame(); 91 } 92 catch (Exception err) 93 { 94 System.err.println("- Error -"); 95 err.printStackTrace(); 96 System.exit(0); 97 } 98 } 99 }); 100 } 101 } 102 | Popular Tags |