I want to switch user and then launch a command under the new user. Actually my code is
String[] commandToRun2 = {"su","-","jboss", "./jboss-cli.sh -c :shutdown(restart=true)"};
ProcessBuilder pb = new ProcessBuilder(commandToRun2);
pb.directory(new File("/home/jboss/soft/jboss-as-7.1.1.Final/bin/"));
Process p = pb.start();
but I can't make it work.