The runtime class represents the runtime environment of a Java program, each Java program has a corresponding runtime instance, which is connected to the runtime environment by the application, and the application cannot create its own runtime instance, but can pass the GetRuntime () method to get the runtime object associated with it.
runtime represents the runtime environment of a Java program and can access information about the JVM, such as the number of processors and memory information.
- import java.io.bufferedreader;
- Import Java.io.InputStreamReader;
- Public class Test {
- Public Static voidMain (string[] args)throwsException
- {
- Runtime Rt=runtime.getruntime ();
- System.out.println (Rt.freememory ());
- System.out.println (Rt.availableprocessors ());
- System.out.println (Rt.totalmemory ());
- System.out.println (Rt.maxmemory ());
- System.out.println (Rt.availableprocessors ());
- }
- }
Runtime can start a single process directly to run the operating system commands
- import java.io.bufferedreader;
- Import Java.io.InputStreamReader;
- Public class Test {
- Public Static voidMain (string[] args)throwsException
- {
- Runtime Rt=runtime.getruntime ();
- Rt.exec ("notepad.exe");
- }
- }
Copyright NOTICE: This article for Bo Master http://www.zuiniusn.com original article, without Bo Master permission not reproduced.
Java Runtime class