How can I do the following in Java code (without invoking the shell directly – not using the pipe operator at all)?
echo path | ./app
Is this the same as starting the app and then writing to STDIN?
I want to be able to start a process from Java and destroy it (and not worry about child processes)
You can use
ProcessBuilder, which wraps theProcessclass to start a process from your Java application, and grab its IO streams usingProcess#getInputStreamandProcess#getOutputStream.