给个小小的例子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");
}
}
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");
}
}
解决方案 »
- 为什么repaint()方法不能调用paint()方法,求教啊!!
- 关于heritrix1.14.3的抓取结果的问题
- java Class.forName 创建多个实例 问题 帮个忙...急
- java中Vector的一些用法
- 我在命名提示符里面输入了d:\java>jar -cvf test.jar *.*
- 在PlainDocument调用fireRemoveUpdate后JFieldText光标移动的问题。
- 一个简单的问题?
- 如何用paint和repaint方法???
- 有谁知道jdk1.5带的demo程序那酷酷的界面是怎么实现的?
- 关于initializer的问题,详情请进
- 高手来帮我看看出了什么问题,解决马上结帖。
- 关于同步的问题
exec(String command,
String[] envp,
File dir)
带3个参数的用法
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
第一个是要执行的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.");
}
呵呵,你的异常的确很搞笑,同时感谢你