1 18 package com.izforge.izpack.installer; 19 20 import java.io.File ; 21 import java.lang.reflect.Method ; 22 23 import com.izforge.izpack.uninstaller.SelfModifier; 24 import com.izforge.izpack.util.Debug; 25 26 32 public class MultiVolumeInstaller 33 { 34 35 protected static String mediadirectory; 37 38 41 public static void main(String [] args) 42 { 43 MultiVolumeInstaller.setMediadirectory(new File (".").getParent()); 45 if ((args.length > 0) && ("-direct".equals(args[0]))) 46 { 47 String [] newargs; 48 if (args.length > 1) 49 { 50 newargs = new String [args.length - 1]; 52 System.arraycopy(args, 1, newargs, 0, args.length - 1); 53 } 54 else 55 { 56 newargs = new String [0]; 58 } 59 MultiVolumeInstaller.install(newargs); 60 } 61 else 62 { 63 try 64 { 65 Class clazz = MultiVolumeInstaller.class; 66 Method target = clazz.getMethod("install", new Class [] { String [].class}); 67 String [] newargs = new String [args.length + 2]; 68 69 System.arraycopy(args, 0, newargs, 2, args.length); 70 newargs[0] = "-mediadir"; 73 newargs[1] = SelfModifier.findJarFile(clazz).getParent(); 74 System.out.println("Setting mediadir: " + newargs[1]); 75 MultiVolumeInstaller.setMediadirectory(SelfModifier.findJarFile(clazz).getParent()); 76 new SelfModifier(target).invoke(newargs); 77 } 78 catch (Exception e) 79 { 80 Debug.trace(e); 81 } 82 } 83 } 84 85 public static String getMediadirectory() 86 { 87 return MultiVolumeInstaller.mediadirectory; 88 } 89 90 public static void setMediadirectory(String mediadirectory) 91 { 92 MultiVolumeInstaller.mediadirectory = mediadirectory; 93 } 94 95 public static void install(String [] args) 96 { 97 if ((args.length >= 2) && ("-mediadir".equals(args[0]))) 98 { 99 MultiVolumeInstaller.setMediadirectory(args[1]); 101 if (args.length > 2) 102 { 103 String [] newargs = new String [args.length - 2]; 105 System.arraycopy(args, 2, newargs, 0, args.length - 2); 106 args = newargs; 107 } 108 else 109 { 110 args = new String [0]; 112 } 113 } 114 Installer.main(args); 116 } 117 } 118 | Popular Tags |