• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Calling .exe file from java  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write this java program that calls a .exe file and read in the result.
The .exe file is written in c and has something like printf("hello") at the end.
I tried to do this:
try {
Process p = Runtime.getRuntime().exec("c:\\test\\a.exe");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
System.out.println(br.readLine());
br.close();
}
catch (Exception err) {
err.printStackTrace();
}
but it keeps giving me null as a result.
Obviously I'm doing something worng, but I can't figure out what is it.
I would really appreciate if someone can help me with it.

Thanks a lot.
 
Sheriff
Posts: 21503
96
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://faq.javaranch.com/java/EaseUp
 
Annie Tang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry. I've been stuck on this problem for several days and I'm getting pretty desperate. I apologize if I make people feel uncomfortable.
 
Rancher
Posts: 42973
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to start by reading this article. It explains all the things that can go wrong when using Runtime.exec.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!