well, basically you'll have to open a bi-directional pipe to the process, which you can read about in the perl faqs. the caveat there being that wait times will be unregulated, and you may send input at the wrong time. it would be better to rewrite the java program to work in a batch mode, just accepting a line-separated series of inputs and figuring out how to use it from there.
if you have problems with a bi-directional pipe, post your questions about that.
HTH "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."