Passing Username & password through shell script to java code

Hi,

I have a shell script (script.sh) in which we are calling java code which asks for
Username:
Password:
for authentication purpose

currently we are passing the credential manually and run the script.

but I am trying

echo -e "user_id\npassword" | script.sh

but its not taking.
pls help

That would work if username and password were read from stdin. Usually, passwords are NOT read from stdin but from e.g. /dev/tty .