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!

7
  • 1
    stackoverflow.com/q/305461 Commented Jul 24, 2013 at 23:28
  • stackoverflow.com/questions/16028488 Commented Jul 24, 2013 at 23:28
  • Do you mean like Runtime.exec("mycommand") ? Commented Jul 24, 2013 at 23:52
  • I am aware of JWS, but my application requires a lot of bandwidth which disables fast multiple requests. Also @PeterLawrey, my application downloads the installer from my own server. The code you provided only lets me use this into my Java code and not the executable. Commented Jul 25, 2013 at 0:18
  • You only listed Java as a language. Are you saying that you don't want an answer in Java but another language? Commented Jul 25, 2013 at 0:24

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.