Java examples for Native OS:Process
create And Execute Android Process
//package com.java2s; import java.io.IOException; public class Main { public static void main(String[] argv) throws Exception { String command = "java2s.com"; System.out.println(createAndExecuteProcess(command)); }//ww w . j a v a 2 s . com private static Process createAndExecuteProcess(String command) throws IOException { String system = System.getProperty("os.name").toLowerCase(); if ("unix".equals(system) || "mac os x".equals(system) || "linux".equals(system)) { return Runtime.getRuntime().exec( new String[] { "/bin/sh", "-c", command }); } else if ("windows".equals(system)) { return Runtime.getRuntime().exec( new String[] { "cmd.exe", "/c", command }); } else { throw new RuntimeException("Unknown OS [" + system + "]"); } } }