http://code.google.com/p/expect4j/
A powerful feature of Tcl has always been its integration with the Expect library [L1 ]. As Tcl has been ported to the Java platform [L2 ], certain C-based libraries have been left behind. Expect4j is an attempt to rewrite Expect in Java and provide bindings to the TclJava interpreter. The goal is to be able to port existing Tcl code bases that use Expect directly to Java without changes. The current version has successfully run a 10,000 line Tcl script which heavily depends on Expect for its operation.
MAKR (2009-02-24) added references to other wiki pages in above text. So far Expect4J lacks support for TTY/PTY handling. It is therefore not possible to drive the password prompts of su, ssh, or the like. For privileged operations, however, newer implementations of sudo could be used, as it is scriptable but has otherwise nothing to do with this topic.