import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Main { public static void main(String[] args) { Runtime r = Runtime.getRuntime(); String command = "ls *.*"; String[] cmd = { "/bin/sh", "-c", command }; try { Process p = r.exec(cmd); p.waitFor(); BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = b.readLine()) != null) { System.out.println(line); } b.close(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }