Runtime: Each Java application has a runtime class instance that enables the application to connect to the environment in which it is running.
One of the methods:
The exec (String command) executes the specified string commands in a separate process, which is the ability to open the software directly and fill in the software name
1 Public classRuntimedemo {2 Public Static voidMain (string[] args)throwsIOException {3Runtime r =runtime.getruntime ();4 //r.exec ("winmine"); open minesweeper software5 //r.exec ("notepad"); Open Notepad software6 //r.exec ("Calc");//Open Calculator7 //r.exec ("shutdown-s-T 10000");//timed off. Shutdown after 10000 milliseconds8 //r.exec ("shutdown-a");//Cancel Shutdown command9 }Ten } One A /* - * Part of the runtime source code: The use of a singleton mode of the A Hungry man type - * the * Class Runtime { - * Private Runtime () {} - * private static runtime currentruntime = new Runtime (); - * public static Runtime GetRuntime () { + * return currentruntime; - * } + * } A */
Java 23-3 Single-instance mode implementation Runtime class