Book description
Java 7 Recipes offers solutions to common programming problems encountered every day while developing Java-based applications. Fully updated with the newest features and techniques available, Java 7 Recipes provides code examples involving Servlets, Java FX 2.0, XML, Java Swing, and much more. Content is presented in the popular problem-solution format: Look up the programming problem that you want to solve. Read the solution. Apply the solution directly in your own code. Problem solved!
The problem-solution approach sets Java 7 Recipes apart from other books on the topic. Java 7 Recipes is focused less on the language itself and more on what you can do with it that is useful. The book respects your time by always focusing on a task that you might want to perform using the language. Solutions come first. Explanations come later. You are free to crib from the book and apply the code examples directly to your own projects.
Covers all-new release of Java: Java 7
Focuses especially on up-and-coming technologies such as Java FX 2.0
Respects your time by focusing on practical solutions you can implement in your own code
What you'll learn
Develop Java SE applications using the latest in Java SE technology
Create great-looking user interfaces with Java Swing and Java FX 2.0
Build web-based applications around Java Servlet technology
Generate graphics and work with media such as sound and video
Implement web services and applications to invoke them
Exploit the power of XML from within your Java applications
Who this book is for
This book is for experienced Java programmers new to Java 7 and those with some experience with Java 7.
Table of contents
- Title
- Dedication
- Contents at a Glance
- Contents
- About the Authors
- About the Technical Reviewers
- Acknowledgments
- Introduction
-
Chapter 1: Getting Started with Java 7
- 1-1. Downloading and Installing Java 7
- 1-2. Configuring the CLASSPATH
- 1-3. Writing an Executable Java Class
- 1-4. Compiling and Executing Java Class
- 1-5. Printing Output
- 1-6. Passing Arguments via the Command Line
- 1-7. Obtaining and Setting Environment Variable Values
- 1-8. Documenting Code with Javadoc
- 1-9. Marking Features as Deprecated
- 1-10. Creating Methods in a Class
- 1-11. Passing Arguments to Methods and Returning Values
- 1-12. Organizing Code with Packages
- 1-13. Accepting Keyboard Input from the Command Line
-
Chapter 2: Strings
- 2-1. Obtaining a Subsection of a String
- 2-2. Comparing Strings
- 2-3. Trimming Whitespace
- 2-4. Changing the Case of a String
- 2-5. Concatenating Strings
- 2-6. Converting Strings to Numeric Values
- 2-7. Iterating Over the Characters of a String
- 2-8. Finding Text Matches
- 2-9. Replacing All Text Matches
- 2-10. Determining Whether a File Name Ends with a Given String
-
Chapter 3: Numbers and Dates
- 3-1. Rounding Float and Double Values to Integers
- 3-2. Formatting Double and Long Decimal Values
- 3-3. Comparing int Values
- 3-4. Comparing Floating-Point Numbers
- 3-5. Performing Calculations with Complex Numbers
- 3-6. Formatting and Parsing Complex Numbers
- 3-7. Calculating Monetary Values
- 3-8. Randomly Generating Values
- 3-9. Obtaining the Current Date
- 3-10. Adding and Subtracting Days, Months, and Years
- 3-11. Finding the Difference Between Two Dates
- 3-12. Formatting Dates for Display
- 3-13. Comparing Dates
- 3-14. Writing Readable Numeric Literals
- 3-15. Declaring Binary Literals
- Chapter 4: Data Structures, Conditionals, and Iteration
-
Chapter 5: Input and Output
- 5-1. Serializing Java Objects
- 5-2. Serializing Java Objects More Efficiently
- 5-3. Serializing Java Objects as XML
- 5-4. Creating a Socket Connection and Sending Serializable Objects Across the Wire
- 5-5. Obtaining the Java Execution Path
- 5-6. Copying a File
- 5-7. Moving a File
- 5-8. Creating a Directory
- 5-9. Iterating Over Files in a Directory
- 5-10. Querying (and Setting) File Metadata
- 5-11. Monitoring a Directory for Changes
- 5-12. Reading Property Files
- 5-13. Uncompressing Compressed Files
-
Chapter 6: Exceptions and Logging
- 6-1. Catching Exceptions
- 6-2. Guaranteeing that Cleanup Code Runs, No Matter What
- 6-3. Throwing Exceptions
- 6-4. Catching Multiple Exceptions
- 6-5. Catching the Uncaught Exceptions
- 6-6. Managing Resources with try/catch Blocks
- 6-7. Creating an Exception Class
- 6-8. Rethrowing the caught Exception
- 6-9. Logging Events in Your Application
- 6-10. Rotating and Purging Logs
- 6-11. Logging Exceptions
-
Chapter 7: Object-Oriented Java
- 7-1. Controlling Access to Members of a Class
- 7-2. Making Private Fields Accessible
- 7-3. Creating a Class That Can Have Only One Instance
- 7-4. Generating Instances of a Class
- 7-5. Creating Reusable Objects
- 7-6. Defining an Interface for a Class
- 7-7. Constructing Instances of the Same Class with Different Values
- 7-8. Interacting with a Class via Interfaces
- 7-9. Making a Class Cloneable
- 7-10. Comparing Objects
- 7-11. Extending the Functionality of a Class
- 7-12. Defining a Class Template
- 7-13. Increasing Class Encapsulation
-
Chapter 8: Concurrency
- 8-1. Starting a Background Task
- 8-2. Updating (and Iterating) a Map
- 8-3. Inserting a Key into a Map Only If the Key is not Already Present
- 8-4. Iterating Through a Changing Collection
- 8-5. Coordinating Different Collections
- 8-6. Splitting Work into Separate Threads
- 8-7. Coordinating Threads
- 8-8. Creating Threadsafe Objects
- 8-9. Implementing Threadsafe Counters
- 8-10. Breaking Down Tasks into Discrete Units Of Work
- Chapter 9: Debugging and Unit Testing
-
Chapter 10: Unicode, Internationalization, and Currency Codes
- 10-1. Converting Unicode Characters to Digits
- 10-2. Creating and Working with Locales
- 10-3. Setting the Default Locale
- 10-4. Searching Unicode with Regular Expressions
- 10-5. Overriding the Default Currency
- 10-6. Converting Byte Arrays to and from Strings
- 10-7. Converting Character Streams and Buffers
-
Chapter 11: Working with Databases
- 11-1. Connecting to a Database
- 11-2. Handling Connection and SQL Exceptions
- 11-3. Querying a Database and Retrieving Results
- 11-4. Performing CRUD Operations
- 11-5. Simplifying Connection Management
- 11-6. Guarding Against SQL Injection
- 11-7. Performing Transactions
- 11-8. Creating a Scrollable ResultSet
- 11-9. Creating an Updatable ResultSet
- 11-10. Caching Data for Use When Disconnected
- 11-11. Joining RowSet Objects When Not Connected to the Data Source
- 11-12. Filtering Data in a RowSet
- 11-13. Querying and Storing Large Objects
- 11-14. Storing Array Values
- 11-15. Retrieving Array Values
- 11-16. Invoking Stored Procedures
- 11-17. Handling Resources Automatically
-
Chapter 12: Java 2D Graphics
- Helper Class for This Chapter
- 12-1. Creating Points
- 12-2. Drawing Lines
- 12-3. Drawing Shapes
- 12-4. Filling Shapes
- 12-5. Gradients
- 12-6. Transforming Shapes
- 12-7. Making Complex Shapes
- 12-8. Creating Interactive Shapes
- 12-9. Changing Text Font
- 12-10. Adding Attributes to Text
- 12-11. Measuring Text
- 12-12. Display Multiple Lines of Text
- 12-13. Adding Shadows to Drawings
- 12-14. Printing Documents
- 12-15. Loading and Drawing an Image
- 12-16. Altering an Image
- 12-17. Storing an Image
- Chapter 13: Java3D
-
Chapter 14: Swing API
- 14-1. Creating a GUI
- 14-2. Running a Swing Application
- 14-3. Adding Components to a GUI
- 14-4. Laying Out GUI Components
- 14-5. Generating Events with Buttons
- 14-6. Refreshing a User Interface
- 14-7. Submitting Form Values to a Database
- 14-8. Making a Multi-Window Program
- 14-9. Adding a Menu to an Application
- 14-10. Adding Tabs to a Form
- 14-11. Drawing on a Canvas
- 14-12. Generating and Laying Out Icons
- 14-13. Designing and Manipulating Borders
- 14-14. Creating Text Components
- 14-15. Associating Action Objects with Editing Commands
- 14-16. Creating Keyboard Shortcuts
- 14-17. Creating a Document
- 14-18. Developing a Dialog Box
- 14-19. Associating Listeners with a Document
- 14-20. Formatting GUI Applications with HTML
- 14-21. Changing the Look and Feel of a GUI
- 14-22. Distributing a Swing Application
- 14-23. Creating an Animation
- 14-24. Working with the JLayer Component
- 14-25. Adding Printing Support to Swing Components
-
Chapter 15: JavaFX Fundamentals
- 15-1. Installing Required Software
- 15-2. Creating a Simple User Interface
- 15-3: Drawing Text
- 15-4: Changing Text Fonts
- 15-5. Creating Shapes
- 15-6. Assigning Colors to Objects
- 15-7. Creating Menus
- 15-8. Adding Components to a Layout
- 15-9. Generating Borders
- 15-10. Binding Expressions
- 15-11. Creating and Working with Observable Lists
- 15-12. Generating a Background Process
- 15-13. Associating Keyboard Sequences to Applications
- 15-14. Creating and Working with Tables
- 15-15. Organizing UI with Split Views
- 15-16. Adding Tabs to the UI
- 15-17. Developing a Dialog Box
- Chapter 16: Graphics with JavaFX
- Chapter 17: Media with JavaFX
-
Chapter 18: Working with Servlets and Applets
- 18-1. Setting Up a Servlet Environment
- 18-2. Developing a Servlet
- 18-3. Packaging, Compiling, and Deploying a Servlet
- 18-4. Registering Servlets without WEB-XML
- 18-5. Setting Initialization Parameters
- 18-6. Handling Requests and Responses
- 18-7. Setting Application-Wide Parameters
- 18-8. Filtering Web Requests
- 18-9. Forwarding Requests to Other Web Resources
- 18-10. Listening for Servlet Container Events
- 18-11. Listening for Attribute Changes
- 18-12. Managing Session Information
- 18-13. Finalization of a Servlet
- 18-14. Creating an Applet
- 18-15. Packaging an Applet and Embedding into a Web Page
- 18-16. Creating Draggable Applets
- 18-17. Loading External Libraries for an Applet
- 18-18. Using Swing Components Within an Applet
-
Chapter 19: Intro to Android
- 19-1. Setting Up a Development Environment with Eclipse
- 19-2. Creating a Basic Application
- 19-3. Compiling and Testing in an Emulator
- 19-4. Constructing a User Interface with XML Layout
- 19-5. Constructing a User Interface Programmatically
- 19-6. Handling Application Events and Activity Changes
- 19-7. Tying All Application Components Together
- 19-8. Handling Incoming Call Events
- 19-9. Building a Tabbed User Interface
- 19-10. Embedding Web Pages into an Application View
- 19-11. Granting Application Device Permissions
- Chapter 20: JavaFX on the Web
- Chapter 21: E-mail
- Chapter 22: XML Processing
- Chapter 23: Networking
- Index
Product information
- Title: Java 7 Recipes: A Problem-Solution Approach
- Author(s):
- Release date: December 2011
- Publisher(s): Apress
- ISBN: 9781430240563
You might also like
book
Java 9 Recipes: A Problem-Solution Approach, Third Edition
Quickly find solutions to dozens of common programming problems encountered while building Java applications. Content is …
book
Beginning Java with WebSphere
provides a step-by-step guide for creating and installing both client- and server-based Java applications using Rapid …
book
Java Enterprise in a Nutshell, Second Edition
Nothing is as constant as change, and this is as true in enterprise computing as anywhere …
book
Flex on Java
Together, Flex and Java make a powerful web development platform—they blend the strengths of Java on …