0

I already have a working code to download certain file from my server. This file is in an executable (a patch installer). I would like to know if it is possible to launch the executable after my java application has downloaded in its own directory. If it is, may I pleas know how?

Also, I know I am asking for too much here, but is it possible to then delete this installer from the computer after it has installed the patch?---I've been working on this but have stumbled upon a lot of nothing...

Thanks a lot in advance!

iWumbo
  • 1

2 Answers2

0

Look at the java docs for the class RunTime, this should allow you to run an executable providing you have permissions to do so.

Pete
  • 1
0

Runtime.getRuntime().exec("command") will execute the input as if you entered it in the command line. So, if you know the path of the exe file (which you should, since you downloaded it), you can launch it like this:

Runtime.getRuntime().exec(executablepath);

Normally you can delete a file by using File.delete(), but in this case the command will still be running if you add delete() right after exec() and it won't be able to delete. Hope that helps!

Sevy
  • 688
  • 4
  • 11