Java Reference
In-Depth Information
The Lifecycle of a Java Program
To better understand how Java code is compiled and executed, and the difference
between Java and other types of programming environments, consider the pipeline
in Figure 1-1 .
n
Figure 1-1. How Java code is compiled and loaded
This starts wth Java source, and passes it through the javac program to produce
class files—which contain the source code compiled to Java bytecode. The class file
is the smallest unit of functionality the platform will deal with, and the only way to
get new code into a running program.
New class files are onboarded via the classloading mechanism (see Chapter 10 for a
lot more detail on how classloading works). This makes the new type available to
the interpreter for execution.
Frequently Asked Questions
In this section, we'll discuss some of the most frequently asked questions about Java
and the lifecycle of programs written in the Java environment.
What is bytecode?
When developers are first introduced to the JVM, they sometimes think of it as “a
computer inside a computer.” It's then easy to imagine bytecode as “machine code
for the CPU of the internal computer” or “machine code for a made-up processor.”
In fact, bytecode is not very similar to machine code that would run on a real hard‐
ware processor. Computer scientists would call bytecode a type of “intermediate
representation”—a halfway house between source code and machine code.
The whole aim of bytecode is to be a format that can be executed efficiently by the
JVM's interpreter.
 
Search WWH ::




Custom Search