Just Java™ 2

Book description

The #1 introduction to J2SE 1.5 and enterprise/server-side development!

An international bestseller for eight years, Just Java™ 2 is the complete, accessible Java tutorial for working programmers at all levels. Fully updated and revised, this sixth edition is more than an engaging overview of Java 2 Standard Edition (J2SE 1.5) and its libraries: it’s also a practical introduction to today’s best enterprise and server-side programming techniques. Just Java™ 2, Sixth Edition, reflects both J2SE 1.5 and the latest Tomcat and servlet specifications. Extensive new coverage includes:

  • New chapters on generics and enumerated types

  • New coverage of Web services, with practical examples using Google and Amazon Web services

  • Simplified interactive I/O with printf()

  • Autoboxing and unboxing of primitive types

  • Static imports, foreach loop construct, and other new language features

  • Peter van der Linden delivers expert advice, clear explanations, and crisp sample programs throughout—including dozens new to this edition. Along the way, he introduces:

  • The core language: syntax, objects, interfaces, nested classes, compiler secrets, and much more

  • Key libraries: date and calendar, pattern matching, network software, mapped I/O, utilities and generic collections

  • Server-side technology: network server systems, a complete tiny HTML Web server, and XML in Java

  • Enterprise J2EE: Sql and JDBC™ tutorial, servlets and JSP and much more

  • Client-side Java: fundamentals of JFC/Swing GUI development, new class data sharing details

  • Companion Web Site

    All the book’s examples and sample programs are available at http://afu.com.



    Table of contents

    1. Title Page
    2. Copyright Page
    3. Quick Contents
    4. Complete Contents
    5. Preface
    6. Acknowledgments
    7. 1. Language
      1. 1. What Can Java Do for Me?
        1. What Java Does for You: Software Portability
        2. Why Portability Matters
        3. Language and Libraries
        4. One Size Doesn't Fit All
        5. Some Light Relief—A Java Desktop Application
      2. 2. Introducing Objects
        1. Downloading and Compiling Java
        2. What Is a Class?
        3. What Is an Object?
        4. Java Digital Clock Program
        5. Summary
        6. Exercises
        7. Some Light Relief—Napster and LimeWire
      3. 3. Primitive Types, Wrappers, and Boxing
        1. Literal Values
        2. boolean
        3. char
        4. int
        5. long
        6. byte
        7. short
        8. Limited Accuracy of Floating Point Types
        9. double
        10. float
        11. Object Wrappers for Primitives
        12. Autoboxing and Unboxing
        13. Performance Implications of Autoboxing
        14. java.lang.Object
        15. java.lang.String
        16. Language Support for String Concatenation
        17. String Comparison
        18. Some Light Relief—Hatless Atlas
      4. 4. Statements and Comments
        1. Organizing Statements
        2. Expression Statements
        3. Selection Statements
        4. Looping Statements
        5. Transfer of Control Statements
        6. Comments
        7. Reading the Java API
        8. Exercises
        9. Some Light Relief—MiniScribe: The Hard Luck Hard Disk
      5. 5. OOP Part II—Constructors and Visibility
        1. Polymorphism Is a Long Word for a Short Topic
        2. Creating New Objects: Constructors
        3. More About Methods
        4. Variable-Arity Methods
        5. Packages
        6. How the JDK Finds Classes
        7. Access Modifiers
        8. Exercises
        9. Some Light Relief—It's Not Your Father's IBM
      6. 6. Static, Final, and Enumerated Types
        1. What Field Modifier static Means
        2. What Field Modifier final Means
        3. Why Enumerate a Type?
        4. Statements Updated for Enumerations
        5. More Complicated Enumerated Types
        6. Some Light Relief—The Haunted Zen Garden of Apple
      7. 7. Names, Operators, and Accuracy
        1. Keywords
        2. Punctuation Terminology
        3. Names
        4. Identifiers
        5. Expressions
        6. Arrays
        7. Operators
        8. Associativity
        9. How Accurate Are Calculations?
        10. Widening and Narrowing Conversions
        11. What Happens on Overflow?
        12. Some Light Relief—Furby's Brain Transplant
      8. 8. More OOP—Extending Classes
        1. Inheritance
        2. Polymorphism
        3. The Class Whose Name Is Class
        4. Exercises
        5. Some Light Relief—The Nerd Detection System
      9. 9. Arrays
        1. Understanding and Creating Arrays
        2. Arrays of Arrays
        3. Have Array Brackets, Will Travel
        4. The Math Package
        5. Some Light Relief—Think Big (and Small)
      10. 10. Exceptions
        1. Run-time Internals: The Heap
        2. Garbage Collection
        3. Run-time Internals: The Stack
        4. Exceptions
        5. The Assert Statement
        6. Further Reading
        7. Some Light Relief—Making an Exception for You
      11. 11. Interfaces
        1. What Problem Does an Interface Solve?
        2. Interface java.lang.Comparable
        3. Interfaces Versus Abstract Classes
        4. Granting Permission Through an Interface—Cloneable
        5. What Protected Really Means
        6. Using Interface Callbacks for GUI Event Handlers
        7. The Class Double
        8. Exercises
        9. Some Light Relief—The Java-Powered Toaster
      12. 12. Nested Classes
        1. Introduction to Nested Classes
        2. Nested Static Classes
        3. Inner Member Classes
        4. Inner Local Classes
        5. Inner Anonymous Classes
        6. How Inner Classes Are Compiled
        7. The Class Character
        8. Exercises
        9. Some Light Relief—The Domestic Obfuscated Java Code Non-Competition
    8. 2. Key Libraries
      1. 13. Doing Several Things at Once: Threads
        1. What Are Threads?
        2. Two Ways to Obtain a New Thread
        3. The Lifecycle of a Thread
        4. Thread Groups
        5. Four Kinds of Threads Programming
        6. Some Light Relief—The Motion Sensor Solution
      2. 14. Advanced Thread Topics
        1. Mutually Exclusive Threads
        2. Communicating Mutually Exclusive Threads
        3. Piped I/O for Threads
        4. Thread Local Storage
        5. Package java.util.concurrent
        6. An Aside on Design Patterns
        7. Further Reading
        8. Exercises
        9. Some Light Relief—Are You Certifiable? I Am.
      3. 15. Explanation <Generics>
        1. Terminology Refresher: Parameters Versus Arguments
        2. The Problem that Generic Code Addresses
        3. What Generic Code Looks Like
        4. Generic Interfaces
        5. Bounds—Requiring a Type Parameter to Implement an Interface or Extend a Parent Class
        6. Some Light Relief—On Computable Numbers with an Application to the Entscheidungsproblem
    9. 3. Server-side Java
      1. 16. Collections
        1. Collection API
        2. List, LinkedList, and ArrayList
        3. Set, HashSet, and SortedSet
        4. The Collections Helper Class
        5. Wildcard Parameters and Generic Methods
        6. Wildcarding a Generic Parameter
        7. Generic Methods
        8. Summary of Collection
        9. Map, HashMap, and TreeMap
        10. Exercises
        11. Some Light Relief—Early Names for Java
      2. 17. Simple Input Output
        1. Getting to Know Java I/O
        2. Design Philosophy
        3. The Class java.io.File
        4. Keyboard I/O
        5. Output
        6. Wrapping Additional Output Classes
        7. Input
        8. Reader Wrappers
        9. Inputting ASCII Characters and Binary Values
        10. Input Stream Wrappers
        11. Further Reading
        12. Exercises
        13. Some Light Relief—The Illegal Prime Number!
      3. 18. Advanced Input Output
        1. Random Access File
        2. Running Commands and Getting Output From Them
        3. Formatted String Output
        4. Writing Objects to Disk
        5. New I/O Package
        6. Memory Mapped I/O
        7. File Locking
        8. Charsets and Endian-ness
        9. Exercises
        10. Some Light Relief—The Illegal T-shirt!
    10. 4. Client Java
      1. 19. Regular Expressions
        1. Regular Expressions And Pattern Matching
        2. Calendar Utilities
        3. Other Utility Classes
        4. Further Reading
        5. Exercises
        6. Some Light Relief—Exchanging Apples And Crays
      2. 20. GUI Basics and Event Handling
        1. All About Event Handling
        2. Tips for Slimming Down Handler Code
        3. Summary of Event Handling
        4. Exercises
        5. Some Light Relief—The Mouse That Roared
      3. 21. JFC and the Swing Package
        1. Java Foundation Classes
        2. All About Controls (JComponents)
        3. Swing Threads—A Caution!
        4. Swing Components
        5. More About Swing Components
        6. Further Reading
        7. Exercises
        8. Some Light Relief—The Bible Code
      4. 22. Containers, Layouts, and AWT Loose Ends
        1. Pluggable Look and Feel
        2. All About Containers
        3. Layout in a Container
        4. Tying up the Loose Ends
        5. Exercises
        6. Some Light Relief—Sky View Cafe: A High Quality Applet
    11. 5. Enterprise Java
      1. 23. Relational Databases and SQL
        1. Introduction to Relational Databases
        2. Primary and Foreign Keys
        3. Relationships
        4. Normal Forms
        5. Relational Database Glossary
        6. Download and Install Mckoi
        7. Basic SQL Primer
        8. Creating and Populating Tables
        9. Querying and Retrieving Data
        10. Subquery Selections
        11. Result Set of a SELECT Query
        12. Updating Values
        13. Deleting Records and Tables
        14. SQL Prepared Statements and Stored Procedures
        15. Exercises
        16. Some Light Relief—Reading the Docs
      2. 24. JDBC
        1. Introduction to JDBC
        2. Installing the Mckoi Database Software
        3. Running the Example Code
        4. Connecting to the Database
        5. Executing SQL Statements
        6. Result Sets
        7. Batching SQL Statements and Transactions
        8. Prepared Statements and Stored Procedures
        9. Complete Example
        10. Database and Result Set Metadata
        11. Further Reading
        12. Exercises
        13. Heavy Light Relief—In Which “I” Spam Myself
      3. 25. Networking in Java
        1. Everything You Need To Know about TCP/IP but Failed to Learn in Kindergarten
        2. A Client Socket in Java
        3. Sending Email by Java
        4. A Server Socket in Java
        5. HTTP and Web Browsing: Retrieving HTTP Pages
        6. A Multithreaded HTTP Server
        7. A Mapped I/O HTTP Server
        8. Further Reading
          1. Bibliography
        9. Exercises
        10. Some Light Relief—500 Mile Limit on Email
      4. 26. Servlets and JSP
        1. Overview of Servlets and JSP
        2. Why Use Servlets?
        3. Releases and Versions
        4. Installing the Tomcat Software
        5. Running the Example Servlets
        6. Ports and Protocols
        7. The HTML to Invoke a Servlet
        8. A Servlet and Its Request/Response
        9. Servlet Request
        10. Response to a Servlet Request
        11. Writing Your Own Servlet
        12. Servlet Operating Cycle and Threading
        13. Java Server Pages
        14. Java Beans in Servlets and JSP
        15. Last Words on JSP, Beans, and Tag Libraries
        16. Further Reading
        17. Exercises
        18. Some Light Relief—Using Java to Stuff an Online Poll
      5. 27. XML and Java
        1. XML Versus HTML
        2. Some Rules of XML
        3. The Document Type Definition (DTD)
        4. What Is XML Used For?
        5. XML Versions and Glossary
        6. JAXP Library Contents
        7. Reading XML With DOM Parsers
        8. A Program That Uses a DOM Parser
        9. Reading an XML File—SAX Parsers
        10. A Program That Uses a SAX Parser
        11. The Factory Design Pattern
        12. Design Pattern Summary
        13. Other Java XML Notes
        14. Further Reading
        15. Exercises
        16. Some Light Relief—View Source on Kevin's Life
      6. 28. Web Services at Google and Amazon
        1. Web Services Introduction
        2. Google Web Services
        3. Amazon Web Services
        4. Conclusions
        5. Some Light Relief—Googlewhacking
      7. A. Downloading Java
      8. B. Powers of Two Table
      9. C. Codesets
    12. Index

    Product information

    • Title: Just Java™ 2
    • Author(s): Peter van der Linden
    • Release date: June 2004
    • Publisher(s): Pearson
    • ISBN: 0131482114