[JAVA][Java 7 Recipes. A Problem-Solution Approach].pdf

(11368 KB) Pobierz
Download at www.eBook12.Com
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Download at www.eBook12.Com
Contents at a Glance
Contents
.................................................................................................................... vi
About
the Authors ................................................................................................... xvi
About
the Technical Reviewers ............................................................................ xviii
Acknowledgments
.................................................................................................. xix
Introduction
............................................................................................................ xxi
Chapter
1: Getting Started with Java 7 .....................................................................1
Chapter
2: Strings ....................................................................................................25
Chapter
3: Numbers and Dates ................................................................................43
Chapter
4: Data Structures, Conditionals, and Iteration ..........................................73
Chapter
5: Input and Output ..................................................................................105
Chapter
6: Exceptions and Logging .......................................................................127
Chapter
7: Object-Oriented Java ...........................................................................145
Chapter
8: Concurrency .........................................................................................185
Chapter
9: Debugging and Unit Testing .................................................................213
Chapter
10: Unicode, Internationalization, and Currency Codes ...........................237
Chapter
11: Working with Databases ....................................................................259
Chapter
12: Java 2D Graphics ...............................................................................321
Chapter
13: Java3D ...............................................................................................397
Chapter
14: Swing API ...........................................................................................413
Chapter
15: JavaFX Fundamentals ........................................................................513
Chapter
16: Graphics with JavaFX ........................................................................579
iv
Download at www.eBook12.Com
CONTENTS AT A GLANCE
Chapter
17: Media with JavaFX .............................................................................621
Chapter
18: Working with Servlets and Applets ....................................................651
Chapter
19: Intro to Android ..................................................................................707
Chapter
20: JavaFX on the Web .............................................................................745
Chapter
21: E-mail .................................................................................................779
Chapter
22: XML Processing..................................................................................787
Chapter
23: Networking .........................................................................................805
Index
......................................................................................................................823
v
Download at www.eBook12.Com
Introduction
The Java programming language was first introduced in 1995 by Sun Microsystems. Derived from
languages such as C and C++, Java was designed to be moreintuitive and easier to use than older
languages, specifically due to its simplistic object model and automated facilities such as memory
management. At the time, Java drew the interest of developers because of its object-oriented, concurrent
architecture; excellent security and scalability; and because applications developed in the Java language
could be run on any operating system that contained a Java Virtual Machine (JVM). Since its inception,
Java has been described as a language that allows developers to “write once, run everywhere” as code is
compiled into class files that contain bytecode, and the resulting class files can run on any compliant
JVM. This concept made Java an immediate success for desktop development, which later branched off
into different technological solutions over the years, including development of web-based applications
and rich Internet applications (RIAs). Today, Java is deployed on a broad range of devices including
mobile phones, printers, medical devices, blue ray players, and so on.
The Java platform consists of a hierarchy of components, starting with the Java Development Kit
(JDK), which is composed of the Java Runtime Environment (JRE), the Java programming language, and
platform tools that are necessary to develop and run Java applications. The JRE contains the Java Virtual
Machine (JVM), plus the Java application programming interfaces (APIs) and libraries that assist in the
development of Java applications. The JVMis the base upon which compiled Java class files run and is
responsible for interpreting compiled Java classes and executing the code. Every operating system that is
capable of running Java code has its own version of the JVM. To that end, the JRE must be installed on
any system that will be running local Java desktop or stand-alone Java applications. Oracle provides JRE
implementations for most of the major operating systems, most recently adding Mac OS X to the list.
Each operating system can have its own flavor of the JRE. For instance, mobile devices can run a scaled
down version of the full JRE that is optimized to run Java Mobile Edition (ME) applications.
The Java platform APIsand libraries are a collection of predefined classes that are used by all Java
applications. Any application that runs on the JVM makes use of the Java platform APIs and libraries.
This allows applications to make use of functionality that has been predefined and loaded into the JVM
and leaves developers with more time to worry about the details of their specific application. The classes
that comprise the Java platform APIs and libraries allow Java applications to use one set of classes in
order to communicate with the underlying operating system. As such, the Java platform takes care of
interpreting the set of instructions provided by a Java application into operating system commands that
are required for the machine on which the application is being executed. This creates a façade for Java
developers to write code against so that they can develop applications; which can be written once and
ran on every machine that contains a relevant JVM.
The JVM and the Java platform APIs and libraries play key roles in the lifecycle of every Java
application. Entire books have been written to explore the platform and JVM. This book will focus on the
Java language itself, which is used to develop Java applications, although the JVM and Java platform APIs
and libraries will be referenced as needed. The Java language is a robust, secure, and modern object-
oriented language that can be used to develop applications to run on the JVM. The Java programming
language has been refined over several iterations and it becomes more powerful, secure, and modern
with each new release. This book covers many features of the Java programming language from those
that were introduced in Java 1.0 through those that made their way to the language in Java 7. In 2011,
xxi
Download at www.eBook12.Com
Zgłoś jeśli naruszono regulamin