The use of many of the system's functions is equivalent to Runtime.getruntime (), which shows how closely the connection between the system and runtime is, in fact, the system is dependent on the runtime class.
The runtime functions as follows:
The runtime class differs from the system class, and its functions are mostly static, with only one static function GetRuntime (). Each Java application has a runtime instance that enables the application to connect to its running environment, which allows us to obtain a runtime () instance where the application cannot create its own runtime instance and then invoke other functions.
(1) Viewing system memory
Long Freememory ();//Returns the idle memory of the Java Virtual Machine long maxmemory ();//returns the maximum amount of storage that the Java virtual machine is attempting to use long totalmemory ();//returns the total RAM of the Java Virtual machine
The code is as follows:
Package Org.test.envm;public class Runtimeevnt {public static void main (string[] args) {//TODO auto-generated method stub SYSTEM.OUT.PRINTLN ("Total Memory:" +runtime.getruntime (). TotalMemory ()); SYSTEM.OUT.PRINTLN ("Maximum amount of Memory:" +runtime.getruntime (). MaxMemory ()); SYSTEM.OUT.PRINTLN ("Idle Memory:" +runtime.getruntime (). Freememory ());}}
(2) terminating the virtual machine
You can use exit (int status) to start the shutdown sequence for a virtual machine
You can use halt (int status) to force the termination of a virtual machine that is currently running
(3) Operating System program
1. Open Notepad
Runtime.getruntime (). EXEC ("notepad");
2. Open Word
Runtime.getruntime (). EXEC ("cmd/c start Winword");
3. Perform batch processing
Runtime.getruntime (). EXEC ("cmd.exe/c d:/demo/run.bat");
This article is from the "Ah Cool blog source" blog, please make sure to keep this source http://aku28907.blog.51cto.com/5668513/1773944
Java Common entity class--runtime class