Im just looking for function that can run some .exe files But I didn't find that function in Java ShellExecute(Operation, File, Parameters, Directory, ShowCmd : String) is there a function like that?
Asked
Active
Viewed 529 times
0
-
1Regarding the previous close: ShellExecute is not the same as `Runtime.exec`. – Joachim Sauer Apr 29 '20 at 11:46
-
Thanks for the correction so there are not functions like that? – Apr 29 '20 at 13:35
-
Besides how can I count the answer as right?I'm using mobile version – Apr 29 '20 at 13:37
-
Take a look at https://www.baeldung.com/run-shell-command-in-java – Nikolai Shevchenko Apr 29 '20 at 19:36
1 Answers
1
java.awt.Desktop
provides some of that functionality:
browse
can be used to open the default browser for a specific URIopen
opens a file for viewing (with the default viewer of the OS)edit
opens a file for editing (with the default editor of the OS)- ...
If you want to run arbitrary exe files, however, then Runtime.exec
is the way to go (but using it can be tricky, as you need to consume all streams for it to not lock up).

Joachim Sauer
- 302,674
- 57
- 556
- 614