Thanks for sharing, why would you do that in Java?
Especially since you apparently rely on expect anyway.
Why not one of
- bash
- python
- tcl
so it's easy to extend.
I code in Java, that's my language of choice. The script is launched from my local machine which is Windows.
The script remains extensible, that's up to any user with a motive to do it.