Runtime.getRuntime().exec problem win serv 2003 versus win serv 2008
I have some java code as follows:
try {
  String outString ="java -jar C:\\ami\\bin\\ImmediateSubmit.jar 12345 localhost";
  Runtime.getRuntime().exec(outString);
  out.println("SUBMITTED");
} 
catch (IOException e) {
  System.out.println("IO Exception parse");
  out.println("FAILED");
  e.printStackTrace();
}
It works fine in win serv 2003 but not in win ser开发者_运维知识库v 2008.
Any ideas why?
Read both the stdout and stderr streams of the Process returned by Runtime#exec().
Process process = Runtime.getRuntime().exec(command);
InputStream stdout = process.getInputStream();
InputStream stderr = process.getErrorStream();
This will return whatever you'd normally see when entering the command plain in command prompt, including errors. Your answer may be in there. Long story short: When Runtime.exec() won't, this is an excellent article explaining its pitfalls in depth. Read all the 4 pages. It contains helpful code snippets.
My guess is that either java isn't recognized as a command (e.g. missing in %PATH%), or that it's an user permission issue. At least, that are the most common causes in cases like that.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论