Skip to content
A fork of the Expect4J project at
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Added unit tests for BufferChangeLogger mechanism Jun 18, 2015
.gitignore Added .gitignore Aug 27, 2013
LICENSE Updated Apache-2.0 LICENSE file Aug 29, 2013 Added the expect4j-users mailing list to the README Oct 22, 2013
pom.xml Preparing for 1.10-SNAPSHOT dev cycle Jun 18, 2015



A powerful feature of Tcl has always been its integration with the Expect library ( As Tcl has been ported to the Java platform ( 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 it operation.

Expect is the kitchen sink of IO control. It supports control of processes and sockets, and a complex method of match multiple patterns at the same time. These are needed in some applications, but it complicates the API a tad. Especially when it used in Java which doesn't support closures natively. There are other libraries which offer a more concise API, e.g. enchanter ( enchanter is a very good library and it is highly recommended for automating ssh/telnet sessions. But when Expect syntax is needed, Expect4j is the way to go.

Excellent article on using expect4j:

Getting Started


  • Maven 3

Build instructions:


# Checkout the repository
git clone

# Change to the workspace
cd expect4j/

# Build everything via maven
mvn clean install


Have questions about Expect4J? Please join our users group at!forum/expect4j-users to ask your questions and get help from other Expect4J users.

Copyright and Licensing

Copyright © 2007 Justin Ryan
Copyright © 2013 Chris Verges <>

Licensed under the terms of the Apache Public License v2.0.

You can’t perform that action at this time.