I am trying to integrate a non-Java executable into a Java webapp on the server-side (Linux).
Some details about the executable:
Written in C++. The executable takes some input either from stdin or file and generates an output file. The executable is not designed to be a long running process i.e it generates an output and then dies out.
While starting an individual process for the executable is fairly inexpensive, the number of calls made to it can be high. This can result in spawning too many processes which could degrade server performance.
How can I write some wrapper or utility (in Java) around this exe, that I can run efficiently as either
- a thread from within my Java app
- a long-running external process
PS: I know that I can start an external process using Runtime or ProcessBuilder in Java and could probably make it multi-threaded and use some queueing too, but that does not solve the issue of starting the process over and over again.