Using System Resources |
Runtime
Object (notes)
At the core of the Java runtime environment are the Java virtual machine, the Java interpreter, and the host operating system.
The oval labelled Runtime in the diagram represents the current runtime environment and is an instance of the
Runtime
class. The current runtime environment could be anything from Sun's implementation of the Java virtual machine and interpreter running on Solaris to ACME Company's implementation of the virtual machine and interpreter running on the ACME toaster.
Runtime
objects provide two services. First, they communicate with the components of the runtime environment--getting information and invoking functions. Second,Runtime
objects are also the interface to system-dependent capabilities. For example, UNIXRuntime
objects might support thegetenv
andsetenv
functions. OtherRuntime
objects, such as for Mac OS, might not supportgetenv
andsetenv
because the host operating system doesn't support these functions, but they might support others.Because the
Runtime
class is tightly integrated with the implementation of the Java interpreter, the Java virtual machine, and the host operating system, it is system-dependent. If objects in your program message theRuntime
object directly, you sacrifice the system indepedent nature of you Java program. In general, this is not a good idea (particularly for applets).
Using System Resources |