Here you can find the source of exeCmdByOs(String cmd)
public static Process exeCmdByOs(String cmd) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; public class Main { public static Process exeCmdByOs(String cmd) throws IOException { Process process = null;//from w w w .j av a2 s .c o m Runtime runtime = Runtime.getRuntime(); String osName = System.getProperty("os.name"); if (osName.toLowerCase().startsWith("win")) { process = runtime.exec((new String[] { "cmd", "/C", cmd })); } else { process = runtime.exec((new String[] { "sh", "-c", cmd })); } return process; } }