• Post Reply Bookmark Topic Watch Topic
  • New Topic

Runtime.exec() Question  RSS feed

 
JThomas2002
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have one question about Runtime.exec().
I am trying to use Runtime.getRuntime.exec() to run another program (e.g. a.exe). But a.exe needs an input file or standard input. Does anyone know how to pass in this input file or standard input?
Thank you.
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JThomas2002
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just pass that along as part of your paramanter to the exec command.
for example
<Code>Runtime.getRuntime().exec("java tmp.java");</Code>
Using the second param, you can even specify which directory to exec in.
HTH,
M
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a bunch of different exec methods that let you set up the command line in different ways. All detailed in the JavaDocs.
 
Erik Pragt
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javaworld (http://www.javaworld.com) also has a lot of good articles about it.. you coudl also try that.
Good luck,
Erik
 
Juanjo Bazan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a String array to set the command and the arguments for it:
String[] a=new String()[]{"program.exe", "param 1", "param 2"};
Runtime.getRuntime().exec(a);
[ July 01, 2002: Message edited by: Juanjo Bazan ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!