This is really weird and eating away my brains. I am using Runtime.exec to start another jvm and it quietly exits even without starting.
p = Runtime.getRuntime().exec("java classname", null, new File(workdir));
The process exits immediately. I briefly see the process in taskmanager and it goes off. I even tried to capture the output.
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String errString = "Error Details:\n";
String line;
while((line = br.readLine()) != null)
errString = errString.concat(line).concat("\n");
The line is null at the first readline call. I know i could use ProcessBuilder but i am on java 1.4 and i cannot go for 1.5. Please help.
Thanks, Bikash
尝试将命令放在命令行数组中:
Runtime.getRuntime().exec(new String[] {"java", "classname"}, null, new File(workdir));
当人们遇到Runtime.exec()问题时,我总是指向这个站点
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.