zoukankan      html  css  js  c++  java
  • java 23


    Runtime:每个 Java 应用程序都有一个 Runtime 类实例,使应用程序能够与其运行的环境相连接。
    其中一个方法:
      exec(String command) 在单独的进程中执行指定的字符串命令,就是可以直接打开软件,里面填写软件名称

     1 public class RuntimeDemo {
     2 public static void main(String[] args) throws IOException {
     3 Runtime r = Runtime.getRuntime();
     4 //r.exec("winmine"); 打开扫雷软件
     5 //r.exec("notepad"); 打开记事本软件
     6 //r.exec("calc");//打开计算器
     7 //    r.exec("shutdown -s -t 10000");//定时关机。10000毫秒后关机
     8 //r.exec("shutdown -a"); //取消关机命令
     9 }
    10 }
    11 
    12 /*
    13 *    Runtime的部分源码:使用了单例模式的饿汉式
    14 *
    15 * class Runtime {
    16 * private Runtime() {}
    17 * private static Runtime currentRuntime = new Runtime();
    18 * public static Runtime getRuntime() {
    19 * return currentRuntime;
    20 * }
    21 * }
    22 */
    何事都只需坚持.. 难? 维熟尔。 LZL的自学历程...只需坚持
  • 相关阅读:
    5-JVM常用的命令
    4-JVM 参数
    3-JVM垃圾回收算法和垃圾收集器
    2-JVM内存结构
    1-JVM基础
    非常短的git学习笔记
    白话马尔科夫链蒙特卡罗方法(MCMC)
    写了个小游戏,来玩
    胡小兔的 高考2019 游记
    机房志 | 一篇中二的文章
  • 原文地址:https://www.cnblogs.com/LZL-student/p/5952279.html
Copyright © 2011-2022 走看看