tnorgd
tnorgd

Reputation: 1602

Java library for calling exteral programs

I am looking for a JAVA library that facilitates running external programs. Now I run them "manually" in a separate thread and capture I/O.

I have several different external tools to run and what I need is a uniform approach to do that. The tasks I have to handle includes: - preparing input files according to predefined templates - running the commands - waiting for the results and parsing output files - maintaining the pipeline

The whole pipeline can be considered as a graph with external tools as nodes and data flow as edges. It would be great if the software could run some of the commands in parallel threads, if the data flow permits.

Is there an existing solution of such problems?

Based on the answers I got I feel I have to clarify: I don't need pipes. Data flow can be solved with files, which I need anyway. Moreover, pipes have to be linear (1 output -> 1 input) but I need a graph

I already have a kind of a prototype in python - a bunch of scripts. It is good but as for me - not scalable. Moreover some of the programs I call are in java, so making the whole thing in java would be handy. Best, Tim

Upvotes: 2

Views: 289

Answers (2)

gbvb
gbvb

Reputation: 886

I would think ant should be perfect for this. It also has fairly good java library to do file processing. Between that and maybe velocity templates, i would think you should be able to do what you want.

Upvotes: 1

Brian Agnew
Brian Agnew

Reputation: 272337

If you're on Unix, have you thought about building a Unix shell command line dynamically (using pipes, redirection, tee etc.) and then spawning this one command off using ProcessBuilder or similar, and (say) /bin/sh -c ?

It means you're making use of an existing working infrastructure that handles pipes, buffering, error collection and managing resources.

Upvotes: 1

Related Questions