aspose file tools*
The moose likes Beginning Java and the fly likes Run .exe file and return boolean true after successful installation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Run .exe file and return boolean true after successful installation" Watch "Run .exe file and return boolean true after successful installation" New topic
Author

Run .exe file and return boolean true after successful installation

Anuj Joshi
Greenhorn

Joined: Feb 05, 2009
Posts: 22
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

Joined: Oct 13, 2005
Posts: 38348
    
  23
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Run .exe file and return boolean true after successful installation