• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help - Using invokelater with Runtime.exec..  RSS feed

Hema Sukumar
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm developing an installation wizard using Swing.
Basically the GUI screen displays the info about the product to be installed & when the user clicks the install button it should call the setup.exe for that product.
What I have done is..
In the actionperformed () method, I have used runtime.exec to call the setup.exe for that particular product. It works & does the installation.
After the installation is complete , I want to show a new window saying that the installation is successful . Rightnow, it shows the window
while the installation is halfway through.
How do I use the invokelater or invokeandwait method to acheive this ?
Here is the sample code that I'm using..
public void actionPerformed(ActionEvent e)
if (e.getActionCommand().equals("Back"))
System.out.println("Installing Modem Drivers....\n");
Runtime rt = Runtime.getRuntime();
String[] call =c:/hema/modem/setup.exe"};

try {
Process proc = rt.exec(call);
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
while(br.readLine() != null){

System.out.println("Process exit code is: " + proc.exitValue());
System.out.println("Process wait for code is: " + proc.waitFor());
//Window that I would like to show up after the external installation is complete
Runnable Update = new Runnable() {
public void run() {
SuccessPanel msp= new SuccessPanel();
} ;

catch(IOException ioe) {
System.err.println( "IOException starting process!");
catch(InterruptedException ie) {
System.err.println("Interrupted waiting for process!");


Has anybody done this before ? Any inputs is highly appreciated !!
Nathan Pruett
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime.exec() returns a Process object... which has a method called waitFor() that causes the current thread (in your program) to wait until the process ends. I would personally do this in a separate thread because you don't want to have redraw problems... You can use the exitValue() method to see if the program exited sucessfully or not.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!