public class ThreadTest {
public static void main(String[] args) throws Exception{
Runtime runtime = Runtime.getRuntime();
Process calc = runtime.exec("calc");
}
}
运行后弹出系统计算器
该代码示例展示了如何在Java中通过Runtime类的exec方法执行系统命令,从而弹出Windows系统的计算器应用。
public class ThreadTest {
public static void main(String[] args) throws Exception{
Runtime runtime = Runtime.getRuntime();
Process calc = runtime.exec("calc");
}
}
运行后弹出系统计算器
2812
474

被折叠的 条评论
为什么被折叠?
