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.
Hello Zhishan and welcome to the Ranch! First and most important, are you familiar with situations When Runtime.exec() won't? If not, be sure to read all four parts of that article and apply the advice you find there.
You will need the -S flag to tell sudo to read its password from stdin.
You can also use gksudo rather than sudo then a password prompt will be displayed. I would also re-enforce Darryl's advice and say it is very very important that you read ALL the sections of the 'traps' article and implement ALL the recommendations. Failure to do so will just cause you grief.