• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

on process exec (String[] cmdarray)

 
christine clarin
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i use this method? for example i have an exe file visual.exe which needs 3 arguments:

visual -din arg1 -cout arg2 -dout arg3

how do i run this from a java program? i tried doing this:

Runtime rt = Runtime.getRuntime ();
Process p1 = rt.exec ("visual -din" + arg1 "-cout" + arg2 + "-dout" + arg3);
p1.waitFor ();

but it does not work, it only works if i fix the arguments:

Runtime rt = Runtime.getRuntime ();
Process p1 = rt.exec ("visual -din arg1 -cout arg2 -dout arg3");
p1.waitFor ();

but i need to run this program such that i can change the arguments, how do i do this. Note: I don't change the arguments from standard input, i just change the arguments within the program. Thank you.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Ernest pointed out in your other thread (we generally try not to cross post the same question to multiple threads), you need spaces between "-din" and the argument. Your build command looks like this:The form of exec that takes a String array could be used by your code like this:
[ February 06, 2005: Message edited by: David Harkness ]
 
christine clarin
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. sorry for the multiple thread. till next time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic