Process p = Runtime.getRuntime().exec(command);
is = p.getInputStream();
byte[] userbytes = new byte[1024];
is.read(userbytes);
I want to execute a shell command in linux os from java . But pmd reports says don’t use java Runtime.exec(). Why? What is the reason ? Is there any alternative for Runtime.exec()?
Unless you’re stuck on an ancient JVM,
java.lang.ProcessBuildermakes it much easier to specify a process, set up its environment, spawn it, and handle its file descriptors.