File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run .exe file and return boolean true after successful installation

 
Anuj Joshi
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i need to execute an any .exe file useing java program
this is the code that i wrote

public class Test3 {
public static void main(String[] args) {
Runtime run = Runtime.getRuntime();
try {

Process pp=run.exec("d:\\jdk1.3\\bin\\javac");
BufferedReader in =new BufferedReader(new InputStreamReader(pp.getErrorStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}

by this code I can run any .exe but how I know whether that exe is installed or not
i.e. I want true boolean value after successful installation and false if installation is failed
and When I run above code System.out.println(line) is not get print..whts d reason
 
Campbell Ritchie
Sheriff
Pie
Posts: 47216
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you emptying the "output" stream?
You aren't calling exec() correctly: do a Google search for "when Runtime.exec() won't" for the classic article by Michael Daconta.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic