score:2

Accepted answer

for the downloading part, you'll need to use binary read/write. see this for further details: working unbuffered streams.

for the executing part, the problem is that the runtime.exec()-method can't launch your executable file.

at least under linux (i can't test it on windows), you'll need the full path to the executable file (or use ./[file] when the file is in the same directory as your application) to be able to execute it.

only giving the command works for executables which are part of your systems path-variable.

score:0

have a look at clickonce: http://en.wikipedia.org/wiki/clickonce we've used that succesfully.

score:0

ive used the following with good results to run command line scripts. you can create a batch script that runs the executable or run it directly using the exec method - probably pass "cmd ". this opens a command prompt from which you can run anything.

public static void runscript(string batchfile, boolean waitforexit0, int retrytime)
{
    try
    { 
        string runstring = "cmd /c start " + (waitforexit0?"/wait ":"") + "/min " + batchfile;
        process p = runtime.getruntime().exec(runstring); //   /c start /wait

        while (true)
        {
            try
            {
                int exit = p.exitvalue();
                if (exit == 0)
                {
                    system.out.println("completed: " + runstring);
                    return;
                }
            }
            catch(exception e)
            {
                string s = "";
            }

            thread.sleep(retrytime);
        }
    }
    catch(exception e)
    {
        string s = "";
    }
}

Related Query

More Query from same tag