Java programming often seems to take place in a safe and isolated
sandbox, as the Java Virtual Machine is often called. The
sandbox makes for a secure
system. The class loading process checks the files for pathologies,
there are no direct memory pointers, and the security manager can
block access to some or all outside resources. In fact, for an applet
the sandbox is so tightly secure that, except for special setups,
it can access almost no resources and can modify none.
Applications, however, even though they also run in the JVM sandbox,
obviously need the capability to communicate with, access, and modify
the real machine to do useful tasks.
A program can reach outside the JVM via:
- Standard I/O
In Chapter 9:
Java we discussed streams,
the File
class, file
choosers, and other tools and techniques for input/output
with the local platform.
- Networking
In Part II: Chapters 13-21
we examined sockets,
URL connections,
RMI, and other tools
for communications with other platforms on the local network and
the Internet.
- JNI
In Chapter 22
we looked at the JNI framework for connecting Java to native code
programs in C. This reduces the portability of an application,
but allows for direct access to the system.
- ClassLoader
The ClassLoader
obtains classes from the local disk, JAR files, and other locations
and loads them into the JVM. Its getResources()
method, invoked from a ClassLoader
object or from the Class
class, can also be used to obtain images, sound clips, and other
files.
- Windows Toolkit
The AWT toolkit object discussed in Chapter
12 provides information on the display system, such as the
screen resolution, screen size, and so forth.
In this chapter we look at some other techniques to access the
world outside the JVM:
Latest update: Dec. 12, 2004
|