java教程

JAVA调用运行CMD命令行

位置:首页 > java教程 > java技巧,2013-04-26
JAVA调用运行CMD命令行,importjava.io.File;publicclassCallExe{publicstaticvoidmain(String[]args){Runtimert=Ru...

JAVA调用运行CMD命令行,

import java.io.File ;
 
public class CallExe {
      public static void main(String[] args) {
          Runtime rt = Runtime.getRuntime();
        Process p = null;
         String fileLac = "";
         try {
             fileLac = "D:\Program Files (x86)\QQ.exe";//所调用的程序路径
             p = rt.exec(fileLac);
         } catch (Exception e) {
             System.out.println("open failure");
         }
     }
 
 }

TAGS:JAVA调用CMD命令

猜你喜欢

NewHot