This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Since you talk of a shell script then I assume you are using some version of Unix/Linux. To get the hostname in Unix/Linux you use the 'hostname' command so you can make your Java program accept command line parameters and pass the hostname as a parameter. For example
java YourProgramMainClass -hostname $(hostname)
I don't understand what you mean by "I also need to pass an input param from Java to script" . Do you mean you want to return a value or values from your Java program back to the script that invoked it? If so then write the values to the Java program 'stdout' using System.out and then read the 'stdout' inside your script.