import java.io.*; public class Main { public static void main(String[] args) { long totalMemory = run.totalMemory(); String[] getServersCommand = {"ls","","servery/*/"," | grep .jar"}; Runtime run = Runtime.getRuntime(); Process pr = null; try { pr = run.exec(getServersCommand); } catch (IOException e) { e.printStackTrace(); } try { pr.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line; try { while ( ( line = buf.readLine() ) != null ) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } } }