Question: I am looking for libraries that I can use to send Unix commands from my Java code. I have already tried Expect4J and Gaynmed, but could not find good documentation with them. My requirements include:

1. Running multiple commands.
2. Capture output for previous command.
3. Take some action/Run different command based on output of last command.

Any pointers will be appreciated.

Answer: 
Is there something wrong with using the `exec()` method?

```
Process p = Runtime.getRuntime().exec("ls -l");

```

You can read from output of this command by doing the following:

```
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));

```
Depending on what you are doing ANT is a good way to go. If you create an ant script you can then execute that script from within java. Ant would also be better supported on other environments