java - 运行可执行文件 (.exe)

package filerun;

import java.io.File;
import java.io.IOException;

public class RunExe {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        
        Runtime run  = Runtime.getRuntime();
        
        File f  = new File("E:\\QQMusic","QQMusic.exe");
        
        
        System.out.println(f.getAbsolutePath());
        
        try {
            run.exec(f.getAbsolutePath());
            System.out.println("运行成功");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
        
    }

}

 

posted @ 2020-10-21 08:43  武卡卡  阅读(273)  评论(0编辑  收藏  举报