Java Reference
In-Depth Information
Figure 2-17. Opening the NetBeans Java project for the source code for this topic
3.
Select the project and click the Open Project button. The project is opened the project in
the IDE. Use the Project or Files tabs on the left to browse the source code for all chapters
in this topic.
Behind the Scenes
This section will answer some general questions related to compiling and running Java programs. For example,
why do we compile Java source code to bytecode format before running it? What is Java platform? What is a JVM and
how does it work? The detailed discussion of these topics is beyond the scope of this topic. Please refer to the JVM
specification for detailed discussion on any topic related to the JVM functionality. The JVM specification is available
online at http://docs.oracle.com/javase/specs .
Let's look at a simple daily life example. Suppose there is a Frenchman who can understand and speak only
French and he has to communicate with three other persons: an American, a German, and a Russian, and these three
only know one language (English, German, and Russian, respectively). How will the Frenchman communicate to
the other three? There are many ways to solve this problem.
The Frenchman may learn all three languages.
The Frenchman may hire a translator who knows all four languages.
The Frenchman may hire three translators who know French-English, French-German, and
French-Russian.
There are numerous other possible solutions to this problem. Let's consider the similar problem in the context
of running a Java program. The Java source code is compiled into bytecode. The same bytecode needs to be run
without any modification to all operating systems. Designers of Java language chose the third option, which is to have
a translator for each operating system. The job of the translator is to translate the bytecode into machine code, which
is native to the operating system running the translated code. The translator is called a Java Virtual Machine (JVM).
You need to have a JVM for each operating system. Figure 2-18 is a pictorial view of how the JVM acts as a translator
between bytecode (class file) and different operating systems.
 
Search WWH ::




Custom Search