Yes, this kind of thing can work. I once used a language called EASEL (now ESL) whose "database integration" was done via shelled programs and the input / output streams. This is not really EASEL, but conversations looked something like
This is a bit harder in Java. I'm reading stdout from the shell program here. If it writes a zillion lines to errout it will block waiting for somebody to read them. Multiple threads are involved for sure. If you have a conversational request-response model like this you might use Futures to get the response from stdout and errout.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi