Java Reference
In-Depth Information
teristics of Java. By the time you are through this stage, you should have learned all the basics of how
the Java language works so you are ready to progress further into how you can apply it.
4. In the fourth stage, in Chapters 7 through 12, you learn how you deal with errors and how you read
and write files. Of course, file input/output is an essential capability in the majority of applications.
5. The fifth stage is covered by Chapters 13 to 15. These chapters explain how you define generic class
types, which are blueprints for creating sets of similar classes. You also learn about a range of utility
classes and capabilities from the support libraries that you can apply in many different program con-
texts.
6. In the sixth stage, in Chapters 16 to 21, you learn in detail how you implement applications or applets
with a graphical user interface, and how you handle interactions with the user in this context. This
amounts to applying the GUI capabilities provided by the Java class libraries. You also learn how you
manage concurrent threads of execution within a Java program, which is fundamental to effective GUI
programming. When you finish this stage, you should be equipped to write your own fully fledged ap-
plications and applets in Java.
7. In the last stage you learn about the Extensible Markup Language, XML, which is a powerful tool
for representing data that is to be transferred from one computer to another. You apply the Java support
classes for XML in a practical context, writing and reading XML files.
At the end of the topic, you should be a knowledgeable Java programmer. The rest is down to experience.
Throughout this topic I use complete examples to explore how Java works. You should create and run
all of the examples, even the simplest, preferably by typing them in yourself. Don't be afraid to experiment
with them. If there is anything you are not quite clear on, try changing an example around to see what hap-
pens, or better still — write an example of your own. If you're uncertain how some aspect of Java that you
have already covered works, don't look it up right away — try out a few things and see if you can figure it
out. Making mistakes is a very effective way to learn.
THE JAVA ENVIRONMENT
You can execute Java programs on a variety of computers using a range of operating systems. Your Java
programs run just as well on a PC running any supported version of Microsoft Windows as it does on Linux
or a Sun Solaris workstation. This is possible because a Java program does not execute directly on your
computer. It runs on a standardized environment called the Java 2 Platform that has been implemented as
software in the form of the Java Runtime Environment (JRE) on a wide variety of computers and operating
systems. The Java Platform consists of two elements — a software implementation of a hypothetical com-
puter called the Java Virtual Machine (JVM) and the Java Application Programming Interface (Java API) ,
which is a set of software components that provides the facilities you need to write a fully fledged interact-
ive application in Java.
A Java compiler converts the Java source code that you write into a binary program consisting of byte-
codes . Bytecodes are machine instructions for the JVM. When you execute a Java program, a program called
the Java interpreter inspects and deciphers the bytecodes for it, checks it out to ensure that it has not been
tampered with and is safe to execute, and then executes the actions that the bytecodes specify within the
JVM. A Java interpreter can run standalone, or it can be part of a web browser such as Google Chrome,
Mozilla Firefox, or Microsoft Internet Explorer where it can be invoked automatically to run applets in a
web page.
Search WWH ::




Custom Search