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 serv 2008.
Any ideas why?
Read both the stdout and stderr streams of the
Processreturned byRuntime#exec().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
javaisn’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.