Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

create process problem  RSS feed

 
Ke Li
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to call another software from my java program. And the
source code is:
Runtime r = Runtime.getRuntime();
Process p = null;
try {
p = r.exec("racer.exe");
}catch (Exception e) {
System.out.print(e.getMessage());
}
The software "racer.exe" must be started in MS-DOS environment and I
compile and execute my java program also in MS-DOS environment. Now
the problem is there is no error displayed when the program is
complied and executed. But actually the software "racer.exe" is not
activated. With the same code, I tried to call other software running
on Windows environment and it works. I don't know what the problem.
Does it because the software and my program both runs on MS-Dos
environment? Could you please give me some ideas?
Thanks a lot,
Best Regards,
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chances are there's an error message for you on the Process' error stream. This is something you have to read yourself with getErrorStream(). But this is best done from a separate thread, since you also (usually) need to read from standard output using getInputStream() and this may be simultaneous. A good solution is presented in this JavaWorld article on common exec() problems. Hope that helps...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!