Java Data Type Tutorial - Java Runtime.exec(String command)








Syntax

Runtime.exec(String command) has the following syntax.

public Process exec(String command)  throws IOException

Example

In the following code shows how to use Runtime.exec(String command) method.

//from  ww  w.  j a  va 2s.  co  m
public class Main {

   public static void main(String[] args) {
      try {
         // create a process and execute notepad.exe
         Process process = Runtime.getRuntime().exec("notepad.exe");

      } catch (Exception ex) {
         ex.printStackTrace();
      }

   }
}