Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.DataOutputStream; import java.io.IOException; public class Main { static void runCommandWithRoot(String command) { try { Process p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); os.writeBytes(command); os.writeBytes("exit\n"); os.flush(); } catch (IOException e) { e.printStackTrace(); } } }