ProcessBuilder is FUNKY! or is it just me?

I'm trying to run a JAR file in a ProcessBuilder object. my JAR file accepts command line parameters. However, as soon as I start passing it the parameters of the program hangs or does not do anything. Here is my code:
               

String list[] = {"java","-jar \\program\\java\\update\\CMDLineUpdateDD1.jar -c \\program\\java\\update\\config.xml"};
                    
ProcessBuilder b = new ProcessBuilder(list);
Process p = b.start();
                    
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=null;

while((line=input.readLine()) != null) {
      log.info(line);
                      
 }

int exitVal = p.waitFor();
What happens is that it works when I just 'java' and "-jar" settings. " However, this pot accepts also a few parameters of command line similar to the one shown above. If I add one of these parameters, the program runs nothing. It ends normally, but no program has been run.

I tried the above variable 'list' in the following way:
//all parameters completely separated...
String list[] = {"java","-jar","\\program\\java\\update\\CMDLineUpdateDD1.jar","-c","\\program\\java\\update\\config.xml"};
//separated by parameter, with equal signs...
String list[] = {"java","-jar=\\program\\java\\update\\CMDLineUpdateDD1.jar","-c=\\program\\java\\update\\config.xml"};
//parameters with spaces
String list[] = {"java","-jar \\program\\java\\update\\CMDLineUpdateDD1.jar","-c \\program\\java\\update\\config.xml"};
in each case, it takes the "java" command and the "jar" parameter, but once I add the "-c" parameter it is unresponsive.

any ideas? Thank you!

Edited by: 960093 Sep 26, 2012 08:08

960093 wrote:

It locks.

THEN MANAGE STDERR AND STDOUT! The main cause of blocking using Runtime.exec () or ProcessBuilder does not stderr.

In your other thread, you received a link to the article "Pitfalls", but you don't seem to have taken well advised of it.

Tags: Java

Similar Questions

Maybe you are looking for