This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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.