Java Reference
In-Depth Information
Java 8 has added the most radical changes seen in the language for almost a decade
(some would say since the birth of Java). Features like lambda expressions and the
overhaul of the core Collections code will change forever the way that most Java
developers write code.
The Java language is governed by the Java Language Specification (JLS), which
defines how a conforming implementation must behave.
n
What Is the JVM?
The JVM is a program that provides the runtime environment necessary for Java
programs to execute. Java programs cannot run unless there is a JVM available for
the appropriate hardware and OS platform we wish to execute on.
Fortunately, the JVM has been ported to run on a large number of environments—
anything from a set-top box or Blu-ray player to a huge mainframe will probably
have a JVM available for it.
Java programs are typically started by a command line, such as:
java < arguments > < program name >
This brings up the JVM as an operating system process that provides the Java run‐
time environment, and then executes our program in the context of the freshly
started (and empty) virtual machine.
It is important to understand that when the JVM takes in a Java program for execu‐
tion, the program is not provided as Java language source code. Instead, the Java
language source must have been converted (or compiled) into a form known as Java
bytecode. Java bytecode must be supplied to the JVM in a format called class files—
which always have a .class extension.
The JVM is an interpreter for the bytecode form of the program—it steps through
one bytecode instruction at a time. However, you should also be aware that both the
JVM and the user program are capable of spawning additional threads of execution,
so that a user program may have many different functions running simultenously.
The design of the JVM built on many years of experience with earlier programming
environments, notably C and C++, so we can think of it as having several different
goals—which are all intended to make life easier for the programmer:
• Comprise a container for application code to run inside
• Provide a secure execution environment as compared to C/C++
• Take memory management out of the hands of developers
• Provide a cross-platform execution environment
These objectives are often mentioned together when discussing the platform.
We've already mentioned the first of these goals, when we discussed the JVM and its
bytecode interpreter—it functions as the container for application code.
Search WWH ::




Custom Search