如题

解决方案 »

  1.   

    这个有必要这样弄吗,如果想运行Dos命令,请到控制台上面去运行,谢谢
      

  2.   

    Process process = Runtime.getRuntime().exec("ipconfig"); 
      

  3.   


    package readFile;import java.io.IOException;public class TestReadFile {
        public static void main(String[] args) throws IOException {
            String f = "e:/a.pdf";
            try {
                Runtime r = Runtime.getRuntime();
                r.exec("cmd   /c   start   " + f);
            } catch (Exception e) {        }
        }
    }
    这个是一个利用java调用 doc的start命令打开了e盘下a.pdf的程序,希望对你有用。
      

  4.   

    Process process = Runtime.getRuntime().exec("命令"); 
    返回的是运行命令的对象
      

  5.   


    public class Test {   
        public static void main(String[] args) {   
            Runtime rt = Runtime.getRuntime();   
            String[] command1=new String[]{"cmd","cd","C:\\Program Files\\Thunder"};   
            String command = "taskkill /F /IM Thunder5.exe";       
            try  
            {   
              rt.exec(command1);//返回一个进程   
              rt.exec(command);   
              System.out.println("success closed");   
            }   
            catch (IOException e)   
            {   
              e.printStackTrace();   
            }   
        }   
      
    }  
    这是在java中调用了一个终止迅雷下载进程的dos命令