The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Essential Java Classes
Lesson: Accessing System Resources

The Runtime Object

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(in the API reference documentation) 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, UNIX Runtime objects might support the getenv and setenv functions. Other Runtime objects, such as for Mac OS, might not support getenv and setenv 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 the Runtime object directly, you sacrifice the system indepedent nature of your Java program. In general, this is not a good idea (particularly for applets).


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.