start another program from an application

Hi Experts,


A simple question...

I have developed an application and from that application I have to start another application that is on my hard disk.
Is there a way to start that outside application from my application.



Thanks
blaroucheAsked:
Who is Participating?
 
hoomanvCommented:
Runtime.getRuntime().exec("F:/ua/EzDownloader.exe");
0
 
gkishorejiCommented:
u can use Runtime.exec to execute that application
0
 
blaroucheAuthor Commented:
The file I have to start is in my F:\ua\EzDownloader.exe

How would I code that?


0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
blaroucheAuthor Commented:

I get the following messasge when I run the code :

java.lang.IllegalThreadStateException: process has not exited
      at java.lang.ProcessImpl.exitValue(Native Method)
      at alarms.Test.main(Test.java:13)


I have to say that when I  excecute EzDownloader,  another message box appears and ask me to push on the button Download now.
0
 
blaroucheAuthor Commented:
I forgot to include my code :

import java.util.*;
import java.io.*;


public class Test
{
    public static void main(String args[])
    {
        try
        {            
            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec("F:/ua/EzDownloader");
            int exitVal = proc.exitValue();
            System.out.println("Process exitValue: " + exitVal);
        } catch (Throwable t)
          {
            t.printStackTrace();
          }
    }
}
0
 
hoomanvCommented:
exitValue() throws IllegalThreadStateException - if the subprocess represented by this Process object has not yet terminated.

You can use waitFor to wait for the process to terminate
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.