Java Reference
In-Depth Information
The Big Cruel Java World
RAD has hidden a great deal of the complexity of creating and running Java applications. For example, if you used
Windows Explorer to display the PC file that contained the Employee class and you double clicked the file name,
Windows would not know what to do with the Java statements in the file. In other words, Windows does not “speak”
Java. Windows (like all operating systems) speaks machine language . Machine language is a set of instructions that
the hardware of the computer understands. When you click on a button, select an option, hit Enter, or select a menu
option, Windows interprets the action and issues the appropriate machine language instructions to the computer
hardware. Because the Java classes contain Java statements, neither the computer hardware nor the operating system
(Windows) can execute those statements. The Java statements need to be converted to machine language.
In Chapter 1, RAD generated the machine language for you. When you run an application in RAD, RAD generates
the machine language commands and the commands are sent to the computer's central processing unit (CPU) for
execution. Because there is no Java Run button in Windows, the programmer must explicitly generate the machine
language and run the machine language version of the Java class. Doing this isn't difficult; it's just easier with RAD.
Java on a PC
As mentioned, Java source statements have to be translated into machine language. This is actually a two-step process
comprised of compiling and interpreting. Compiling Java source code creates bytecode. Bytecode is a “language” that
is neither machine language nor source code. (However, bytecode is a step closer to machine language than source
code.) When a Java application is run or a class is instantiated, the bytecode is translated into machine language. You
may be asking, why bother with bytecode? Translating bytecode takes less time than translating source code (because
bytecode is closer to machine language). In addition, bytecode is the same regardless of the computer system.
In other words, the bytecode generated from the Employee class's source code is the same on a computer running
Windows, Linux, Solaris or any other operating system. This makes the bytecode portable to any computer system.
When the bytecode is interpreted, the unique machine language (for the type of computer system you are working on)
is generated and executed.
Oracle provides the software to compile and interpret Java (for free). There are two primary groupings of the free
software called a JDK and a JRE. The JRE (Java Runtime Environment) has the interpreter (the JVM) not the compiler.
As implied from the earlier discussion of converting bytecode to machine language, the JRE therefore must be unique
for each computer's operating system. In other words, there is a different JRE for Windows, Linux, and Solaris.
In addition to a compiler, Oracle provides other free software tools for Java programmers. All of this
software—compiler, JRE, programmer tools—is provided in a JDK (Java Development Kit sometimes also
abbreviated as SDK). Early releases were simply named JSDK 1.0, JSDK 1.1, and so on. However, there are now
different “editions” of Java and associated JDKs. For instance, there is a Java SE (Java Standard Edition), Java FX,
and Java EE (Java Enterprise Edition). To explain the difference between them simply: SE is used to create client
based applications, FX has functions for a richer client interface and alternative platforms such as mobile phones,
and EE supports applications that have both server and client based components.
Each edition has a JDK included. For instance, a recent release of Java SE 6 is formally called: Java (TM) SE
Development Kit 1.6 Update 25 . However, the acronyms followed by their version and/or release numbers are used
for identification. For example, the files for recent EE and SE releases have the acronyms java_ee_sdk-6u1-jdk and
jdk-6u25 in their names.
However, users don't need everything in the JDK/SDK. To run a Java application all that is needed is the JRE
for your operating system. The JRE contains all the classes (like String ) that make your programming life easier,
the machine language instructions that correspond to the bytecode commands, and the Java Virtual Machine (JVM).
The JVM (i.e., the Java interpreter) is the software that translates bytecode into machine language.
Wasn't life so much simpler in RAD?
Figure 2-14 shows the three steps involved in creating and running a Java application on a PC and the various
Java components involved.
 
Search WWH ::




Custom Search