Is there a Java library for testing command line applications?
There is expect. It is designed to test interactive command-line systems. For non-interactive programs it is easier.
expect is not java, but as pointed out in the comments. The language is irrelevant, as the testing is done from the outside.