给个小小的例子import java.io.IOException;
public class CmdTest{
public static void main(String[] args) throws IOException{
System.out.println("cmd start");
String cmd="cmd /c appletviewer HW.html";
                  //String cmd="cmd /c copy c:\\fileA.txt c:\\fileB.txt";
        Runtime.getRuntime().exec(cmd);
        System.out.println("applet start");
    }
}

解决方案 »

  1.   

    exec(String)带一个参数的我基本知道,但是我想知道的是
    exec(String command,
                        String[] envp,
                        File dir)
    带3个参数的用法
      

  2.   

    Executes the specified string command in a separate process with the specified environment and working directory. 
    This method breaks the command string into tokens and creates a new array cmdarray containing the tokens in the order that they were produced by the string tokenizer; it then performs the call exec(cmdarray, envp). 
    The token parsing is done by a StringTokenizer created by the call:  
    new StringTokenizer(command)
      with no further modification of the character categories. The environment variable settings are specified by envp. If envp is null, the subprocess inherits the environment settings of the current process. The working directory of the new subprocess is specified by dir. If dir is null, the subprocess inherits the current working directory of the current process.Parameters:
       command - a specified system command.
       envp - array of strings, each element of which has environment variable       settings in format name=value.
       dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process.Returns:
       a Process object for managing the subprocess.Throws:
    SecurityException - if a security manager exists and its checkExec method  doesn't allow creation of a subprocess.IOException - if an I/O error occurs
      

  3.   

    晕,还是api,e文不好,谁给翻译一下
      

  4.   

    if(用过dos吗){
       第一个是要执行的executable文件(.exe, .com, .bat in dos),例如dir
       第二个是要执行的命令后面的参数s(复数),例如dir后面的参数  /p /w
       第三个是执行时候的当前路径,也就是提示符表明的那个例如 c:\> 中的C:\
              或者说exe文件快捷方式属性中的开始目录
    }else if(用过cs里面的console){
       第一个好比cs命令行,也就是~掉出来的那个里面的 kick 命令
       第二个好比kick后面要踢的人的名字
       第三个好比你现在处于那个游戏中,de_dust_2, de_aztec?
    }else if(用过开始/运行或者其他命令行操作系统吗){
       上面的两个应该看得懂
    }else{
       throw new RuntimeException("VERY SORRY,I CANNOT HELP YOU.");
    }
      

  5.   

    to  shine333(shine):
    呵呵,你的异常的确很搞笑,同时感谢你