List of usage examples for java.lang Runtime getRuntime
public static Runtime getRuntime()
From source file:Main.java
public static void main(String[] argv) throws Exception { String command = "cat"; Process child = Runtime.getRuntime().exec(command); OutputStream out = child.getOutputStream(); out.write("some text".getBytes()); out.close();//w ww. ja v a 2 s .c o m }
From source file:Main.java
public static void main(String[] args) { try {//from w ww.j a v a 2 s . c om // create a process and execute notepad.exe Runtime runTime = Runtime.getRuntime(); Process process = runTime.exec("notepad.exe"); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { String command = "ls"; Process child = Runtime.getRuntime().exec(command); InputStream in = child.getInputStream(); int c;//from w ww . j a va 2 s .c o m while ((c = in.read()) != -1) { System.out.println(((char) c)); } in.close(); }
From source file:Main.java
public static void main(String[] args) { DecimalFormat df = new DecimalFormat("0.00"); long freeMem = Runtime.getRuntime().freeMemory(); System.out.println(df.format(freeMem / 1000000F) + " MB"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String command = "ls"; Process child = Runtime.getRuntime().exec(command); InputStream in = child.getInputStream(); int c;/*ww w .j ava 2 s . c om*/ while ((c = in.read()) != -1) { System.out.println((char) c); } in.close(); }
From source file:Main.java
public static void main(String[] args) { DecimalFormat df = new DecimalFormat("0.00"); long maxMem = Runtime.getRuntime().maxMemory(); System.out.println(df.format(maxMem / 1000000F) + " MB"); }
From source file:Main.java
public static void main(String[] args) { DecimalFormat df = new DecimalFormat("0.00"); long totalMem = Runtime.getRuntime().totalMemory(); System.out.println(df.format(totalMem / 1000000F) + " MB"); }
From source file:Main.java
public static void main(String[] arg) { Runtime runTime = Runtime.getRuntime(); Main hook = new Main(); runTime.addShutdownHook(new Thread(hook)); }
From source file:Main.java
public static void main(String[] args) throws Exception { Process process = Runtime.getRuntime().exec("ls -al"); process.waitFor();/*from w w w . j av a 2 s .co m*/ int exitValue = process.exitValue(); System.out.println("exitValue = " + exitValue); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = ""; while ((line = reader.readLine()) != null) { System.out.println(line); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Execute a command without arguments String command = "ls"; Process child = Runtime.getRuntime().exec(command); // Execute a command with an argument command = "ls /tmp"; child = Runtime.getRuntime().exec(command); }