Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo
Beginning Java 7

Book Description

Beginning Java 7 guides you through this language and a huge assortment of platform APIs according to the following table of contents:

Chapter 1: Getting Started with Java

Chapter 2: Discovering Classes and Objects

Chapter 3: Exploring Advanced Language Features

Chapter 4: Touring Language APIs

Chapter 5: Collecting Objects

Chapter 6: Touring Additional Utility APIs

Chapter 7: Creating and Enriching Graphical User Interfaces

Chapter 8: Interacting with Filesystems

Chapter 9: Interacting with Networks and Databases

Chapter 10: Parsing, Creating, and Transforming XML Documents

Chapter 11: Working with Web Services

Chapter 12: Java 7 Meets Android

Appendix A: Solutions to Exercises

Appendix B: Scripting API and Dynamically Typed Language Support

Appendix C: Odds and Ends

Appendix D: Applications Gallery

Chapter 1 introduces you to Java and begins to cover the Java language by focusing on fundamental concepts such as comments, identifiers, variables, expressions, and statements.

Chapter 2 continues to explore this language by presenting all of its features for working with classes and objects. You learn about features related to class declaration and object creation, encapsulation, information hiding, inheritance, polymorphism, interfaces, and garbage collection.

Chapter 3 focuses on the more advanced language features related to nested classes, packages, static imports, exceptions, assertions, annotations, generics, and enums. Additional chapters will introduce you to the few features not covered in Chapters 1 through 3.


Chapter 4 largely moves away from covering language features (although it does introduce class literals and strictfp) while focusing on language-oriented APIs. You learn about Math, StrictMath, Package, Primitive Type Wrapper Classes, Reference, Reflection, String, StringBuffer and StringBuilder, Threading, BigDecimal, and BigInteger in this chapter.

Chapter 5 begins to explore Java's utility APIs by focusing largely on the Collections Framework. However, it also discusses legacy collection-oriented APIs and how to create your own collections.

Chapter 6 continues to focus on utility APIs by presenting the concurrency utilities along with the Objects and Random classes.

Chapter 7 moves you away from the command-line user interfaces that appear in previous chapters and toward graphical user interfaces. You first learn about the Abstract Window Toolkit foundation, and then explore the Java Foundation Classes in terms of Swing and Java 2D. Appendix C explores Accessibility and Drag and Drop.

Chapter 8 explores filesystem-oriented I/O in terms of the File, RandomAccessFile, stream, and writer/reader classes. New I/O is covered in Appendix C.

Chapter 9 introduces you to Java's network APIs, such as sockets. It also introduces you to the JDBC API for interacting with databases.

Chapter 10 dives into Java's XML support by first presenting an introduction to XML (including DTDs and schemas). It next explores the SAX, DOM, StAX, XPath, and XSLT APIs. It even briefly touches on the Validation API. While exploring XPath, you encounter namespace contexts, extension functions and function resolvers, and variables and variable resolvers.

Chapter 11 introduces you to Java's support for SOAP-based and RESTful web services. In addition to providing you with the basics of these web service categories, Chapter 11 presents some advanced topics, such as working with the SAAJ API to communicate with a SOAP-based web service without having to rely on JAX-WS. You will appreciate having learned about XML in Chapter 10 before diving into this chapter.

Chapter 12 helps you put to use some of the knowledge you've gathered in previous chapters by showing you how to use Java to write an Android app's source code. This chapter introduces you to Android, discusses its architecture, shows you how to install necessary tools, and develops a simple app.

Appendix A presents the solutions to the programming exercises that appear near the end of Chapters 1 through 12.

Appendix B introduces you to Java's Scripting API along with Java 7's support for dynamically typed languages.

Appendix C introduces you to additional APIs and architecture topics: Accessibility, ByteArrayOutputStream and ByteArrayInputStream, classloaders, Console, Desktop, Drag and Drop, Dynamic Layout, Extension Mechanism and ServiceLoader, File Partition-Space, File Permissions, Formatter, Image I/O, Internationalization, Java Native Interface, NetworkInterface and InterfaceAddress, New I/O (including NIO.2), PipedOutputStream and PipedInputStream, Preferences, Scanner, Security, Smart Card, Splash Screen, Stream Tokenizer, StringTokenizer, SwingWorker, System Tray, Timer and TimerTask, Tools and the Compiler API, Translucent and Shaped Window, and XML Digital Signature.

Appendix D presents a gallery of significant applications that demonstrate various aspects of Java.

Unfortunately, there are limits to how much knowledge can be crammed into a print book. For this reason, Appendixes A, B, C, and D are not included in this book's pages. Instead, these appendixes are freely distributed as PDF files. Appendixes A and B are bundled with the book's associated code file at the Apress website (

Appendixes C and D are bundled with their respective code files on my website at Appendixes C and D are "living documents" in that I'll occasionally add new material to them. For example, I plan to expand Appendix C by also covering Java Naming and Directory Interface, Java Sound, Remote Method Invocation and Corba, Robot, Runtime and Process, Swing Timer, and many other APIs/architecture topics (including a complete tour of Swing components). Of course, it will take time to write about these topics so don't expect all of them to appear at once -- they will slowly emerge in coming months (although smaller topics such as Robot will emerge much faster).

"The eBook version does not provide access to the companion files."

Table of Contents

  1. Title
  2. Contents at a Glance
  3. Contents
  4. About the Author
  5. About the Technical Reviewer
  6. Acknowledgments
  7. Introduction
  8. Chapter 1: Getting Started with Java
    1. What Is Java?
    2. Installing and Working with JDK 7
    3. Installing and Working with NetBeans 7
    4. Java Language Fundamentals
    5. Summary
  9. Chapter 2: Discovering Classes and Objects
    1. Declaring Classes and Creating Objects
    2. Encapsulating State and Behaviors
    3. Initializing Classes and Objects
    4. Inheriting State and Behaviors
    5. Changing Form
    6. Formalizing Class Interfaces
    7. Collecting Garbage
    8. Summary
  10. Chapter 3: Exploring Advanced Language Features
    1. Nested Types
    2. Packages
    3. Static Imports
    4. Exceptions
    5. Assertions
    6. Annotations
    7. Generics
    8. Enums
    9. Summary
  11. Chapter 4: Touring Language APIs
    1. Math and StrictMath
    2. Package
    3. Primitive Type Wrapper Class
    4. Reference
    5. Reflection
    6. String
    7. StringBuffer and StringBuilder
    8. System
    9. Threading
    10. BigDecimal
    11. BigInteger
    12. Summary
  12. Chapter 5: Collecting Objects
    1. The Collections Framework
    2. Legacy Collections APIs
    3. Creating Your Own Collections
    4. Summary
  13. Chapter 6: Touring Additional Utility APIs
    1. Concurrency Utilities
    2. Objects
    3. Random
    4. Summary
  14. Chapter 7: Creating and Enriching Graphical User Interfaces
    1. Abstract Window Toolkit
    2. Swing
    3. Java 2D
    4. Summary
  15. Chapter 8: Interacting with Filesystems
    1. File
    2. RandomAccessFile
    3. Streams
    4. Writers and Readers
    5. Summary
  16. Chapter 9: Interacting with Networks and Databases
    1. Interacting with Networks
    2. Interacting with Databases
    3. Summary
  17. Chapter 10: Parsing, Creating, and Transforming XML Documents
    1. What Is XML?
    2. Parsing XML Documents with SAX
    3. Parsing and Creating XML Documents with DOM
    4. Parsing and Creating XML Documents with StAX
    5. Selecting XML Document Nodes with XPath
    6. Transforming XML Documents with XSLT
    7. Summary
  18. Chapter 11: Working with Web Services
    1. What Are Web Services?
    2. Java and Web Services
    3. Working with SOAP-Based Web Services
    4. Working with RESTful Web Services
    5. Advanced Web Service Topics
    6. Summary
  19. Chapter 12: Java 7 Meets Android
    1. Exploring Android and Android App Architectures
    2. Installing the Android SDK and an Android Platform
    3. Creating and Starting an AVD
    4. Creating, Installing, and Running an App
    5. Summary
  20. Index