使用Runtime类运行本地可执行文件

package jnet;

import java.io.File;

//使用Runtime类运行本地可执行文件对象
public class G {
    public static void main(String[] args) {
        try {
            Runtime rt = Runtime.getRuntime();  //创建执行本地文件对象
//            rt.exec("java F");
//            File file = new File("/F.java");
//            System.out.println(file.getPath());
//            rt.gc(); 调用垃圾回收器   
//            rt.exec("c:/windows/system32/calc.exe");  //调用windows系统自带的计算器
//            rt.exec("c:/windows/system32/cmd.exe");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

posted @ 2020-10-20 22:46  nanfengnan  阅读(196)  评论(0编辑  收藏  举报