Brought to you by EarthWeb
ITKnowledge Logo Login Graphic Click here for MCI WorldCom.
Click here for MCI WorldCom.
ITKnowledge
Find:
 
EXPERT SEARCH ----- nav

EarthWeb Direct

EarthWeb sites: other sites

Previous Table of Contents Next


Part 1
Sun Java Programmer Certification

1  Java and the Java Virtual Machine (JVM)
2  Java Language Internals
3  Java Objects and Exceptions
4  Threads in the Java Platform
5  Java API
6  JDK Supplied Tools
7  Certified Programmer Practice Test #1
8  Certified Programmer Practice Test #2
9  Certified Programmer Practice Test #3

Chapter 1
Java and the Java Virtual Machine (JVM)

The word Java is often used in a confusing manner. For example, saying, “I program in Java,” and, “My browser is Java-enabled” is ambiguous. The first statement refers to the Java programming language, and the second refers to the Java runtime environment, or Java Virtual Machine (JVM). This chapter focuses on the sometimes forgotten aspects of the Java technology suite, which are the Java runtime environment and the JVM.

The Java runtime environment and JVM provide Java programs the underlying framework for their cross-platform nature. For many in the industry, the Java runtime environment and JVM are the black magic pieces of the Java technology. After reading this chapter, you will know all the ins and outs of the Java runtime environment and JVM technologies.

Objectives

  How the JVM executes Java programs
  JVM and JRE internals
  JVM interaction with native resources
  Class file composition
  Cross-platform characteristics of the different JREs


STOP:  Test Yourself! Before reading this chapter, test yourself to determine how much study time you will need to devote to this section.
1.  The JVM architecture makes the following provisions to ensure compatibility across all processors:
A.  Uses a stack-based architecture
B.  Is modeled after the lowest common denominator architecture
C.  Minimizes the use of registers
D.  A and B
E.  A and C
2.  The JVM registers and stack are:
A.  8 bits wide
B.  16 bits wide
C.  32 bits wide
D.  64 bits wide

Answers are located at the end of the Chapter…

The Java Runtime Environment Makes Java Cross-Platform

Objective

The easiest and cleanest way to describe the relationship between Java and the Java runtime environment is to compare both technologies to the way Velcro functions. For instance, if you want to temporarily mount a pair of speakers onto your computer monitor, you could attach strips of opposing pieces of Velcro to your speakers and computer, and then put the devices together. Using Velcro instead of, say, glue, gives you the ability to move the speakers at will, without any adverse effects. Velcro allows you to attach the speaker to whatever you want to attach it to, as long the object has an opposing piece of Velcro on it.

Just as Velcro requires two pieces to operate, so does Java, as displayed in Figure 1.1. A Java executable, or class file, is the first piece, and the Java runtime environment is the second. You can think of the Java runtime environment as the receptor to which the Java executable bonds. The Java runtime environment binds itself to the specific native platform and provides a shield against any platform-specific issues by eliminating machine-specific issues. This shielding is known as a layer of indirection for the Java executable.


Figure 1.1  Java Velcro Effect.

At the time the executable is handed to the Java runtime environment for execution in the JVM , the application can assume a certain set of predefined functionality. It is up to the JVM to shield the application from any platform-specific dependencies. As long as the platform has a JVM affixed to it, all Java executables are able to run. In this way, the Java application binds to the JVM and the JVM, in turn, binds to the specific platform.

One of the most common oversights in the Java world is to say that Java executables can run on any platform . A more correct statement is that Java applications can run on any platform that has an accessible Java runtime environment. Not all platforms are Java-ready, but the list is growing. The Java runtime environment has been announced as a standard facility for the next generation of operating systems produced by all major vendors. For example, the next release of Windows might contain a Java runtime environment. As long as a Java runtime environment is accessible, the Java executable will run, regardless of platform. Soon there will be no distinction between what is a Java-executable and what is native code.


Previous Table of Contents Next
HomeAbout UsSearchSubscribeAdvertising InfoContact UsFAQs
Use of this site is subject to certain Terms & Conditions.
Copyright (c) 1996-1999 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.