- package otherClass;
- import java.io.*;
- import static java.lang.System.*;
- /*
- 此类是一个单例类
- */
- public class RuntimeDemo{
-
- public static void main(String[] args){
-
- Runtime runTime = Runtime.getRuntime();
- Process process = null;
- try{
-
- process = runTime.exec("qq.exe");
- }
- catch(IOException io){
-
- throw new RuntimeException("可执行文件路径有问题。") ;
- }
-
- out.println("让程序停会!");
- try{
-
- Thread.sleep(5000);
- }
- catch(InterruptedException interruptedException){
-
- throw new RuntimeException("线程醒不了,哈哈!") ;
- }
-
- out.println("结束线程。");
- if(process != null){
- process.destroy();
- out.println("进程已经over");
- }
-
- System.out.println("Over!");
- }
- }
复制代码 这是我写的代码,为什么qq程序能打开但是杀不死呀!我也试过notepad.exe(记事本)这个可以被杀,这是什么呀!
|