Execute external command / application from java

I am looking for a package to reliably execute external processes with Java. My criteria:

  • Abstract on the OS. Therefore, if I want to run "foo", it will look for "foo.bat", "foo.exe" under the windows and "foo" under other OSs (or have a way to send the os-> command card),
  • The ability to execute Java classes by simply assigning the name and arguments of the class (so the package finds the java command, copies the jvm flags and then executes)
  • Process stdout and stderr correctly
  • Watchdog / Monitoring Functions

I looked at commons-exec, but it looks like it only answers 3 and 4. Ant has support for execution, but it looks like redundant to use it just for this purpose.

+3
source share
1 answer

You will most likely have to go with "commons-exec" and then roll up your sleeves and write the code.

These are quite specific requirements.

+1
source

Source: https://habr.com/ru/post/1737138/


All Articles