try{
Runtime.getRuntime().exec("cmd /c 执行的文件名");
}catch(Exception e){}
Runtime.getRuntime().exec("cmd /c 执行的文件名");
}catch(Exception e){}
解决方案 »
- ###发个200,问线程同步问题啦,大家看过来
- GZIP压缩所有子目录以及子目录底下的文件问题
- 请问,swing中的控件可以是任意形状的吗?比如,斜线
- jndi如何删除ldap里面的一个目录
- 请问怎么样对JTextArea文本添加新的文本?谢谢
- applet在ie里什么都没有,都是灰色的了。。。。
- 我的尚学堂坦克大战网络版 对方坦克动不了,请大牛们分析分析
- 在线等待,解决后立刻给分!!!!
- import的奇怪问题!!高分送上!!
- 一个问题,如果没人回答,自己最后知道答案了,怎么结掉?
- 连续问了六个问题,没有一个能够真正得到解决,真郁闷!想结帐,又不知道该给谁,好失望!这是什么地方来的!!!
- 菜鸟问题!
import java.io.*; class A {
public static void main(String[] args){
try {
Runtime.getRuntime().exec("cmd /c F:\fpread32.exe");
}
catch (IOException ex) {
System.out.println(ex);
}
}
}不行哦
import java.io.*;public class javaPing{
public static void main(String[] args){
String pingurl=null;
if(args.length>0) {
pingurl=args[0];
}
else {
pingurl="www.sina.com.cn";
}
pingurl="C:\\WINNT\\system32\\ping.exe "+pingurl;
try
{
Process process = Runtime.getRuntime().exec ("pingurl");
InputStreamReader ir=new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader (ir);
String line;
while ((line = input.readLine ()) != null)
System.out.println(line);
}
catch (java.io.IOException e){
System.err.println ("IOException " + e.getMessage());
}
}
}
p.destroy();//退出记事本运行一个外部的程序直接将程序的路径传给Rutime的exec()方法即可。如果要运行一个dos命令,如设置时间,则不能直接使用exec("date ..."),可以通过动态创建一个.bat文件来执行该命令。
public static void main(String[] args){
try {
Runtime.getRuntime().exec(" F:/fpread32.exe");
}
catch (IOException ex) {
System.out.println(ex);
}
}
}