1 45 package org.exolab.jms.net.jvm; 46 47 import java.util.Enumeration ; 48 import java.util.Properties ; 49 50 51 57 public class JVM extends Executor { 58 59 70 public JVM(String mainClass, String classpath, Properties sysProps, 71 String args) { 72 super(getCommand(mainClass, classpath, sysProps, args)); 73 } 74 75 84 private static String getCommand(String mainClass, String classpath, 85 Properties sysProps, String args) { 86 if (classpath == null) { 87 classpath = System.getProperty("java.class.path"); 88 } 89 StringBuffer command = new StringBuffer ("java -cp "); 90 command.append(classpath); 91 command.append(" "); 92 if (sysProps != null) { 93 Enumeration names = sysProps.propertyNames(); 94 while (names.hasMoreElements()) { 95 String name = (String ) names.nextElement(); 96 String value = sysProps.getProperty(name); 97 command.append("-D"); 98 command.append(name); 99 command.append("="); 100 command.append(value); 101 command.append(" "); 102 } 103 } 104 command.append(mainClass); 105 if (args != null) { 106 command.append(" "); 107 command.append(args); 108 } 109 return command.toString(); 110 } 111 } 112 | Popular Tags |