Home How to automatically answer user prompts in Java?
 I'm using a compiled Java file which takes a filename as a parameter and then asks for a username and password (via user input). I am trying to automate this from a shell script, but am running into problems. I'm unable to access the java code, which is why I am having trouble. So the code is called the following way java javaprogram /home/user/securityfile  So, you pass the file, and then it asks you for username and password. After entering those, it's done. Now, I have tried to put the user input into a file and pass it in, but I get an error. java javaprogram /home/user/securityfile < userinputfile  userinput file contains the following text (First line is the username, second line is the password): MattSmith MSpassword136  Does anyone have any ideas? Maybe I am doing it wrong? Here is the error message: Exception in thread "main" java.lang.NullPointerException at ilex.util.UserAuthFile.main(UserAuthFile.java:297)  Thanks