Description
Be among the first to capture an early look at the libraries of Java SE 6, aka Mustang. While J2SE 5.0 is just now starting to become regularly adopted, Java 6 Platform Revealed takes a look at the next release of the Standard Edition platform to come from Sun.New editions of the platform don't happen that frequently, but when they do, there is a lot to learn about quickly. If you want to come up to speed on the feature set as quickly as possible, Java 6 Platform Revealed will place you well ahead of the pack. You'll find 10 chapters of how to use the JSR implementations and library improvements that are now a part of Mustang. You'll learn about the scripting features of AWT and Swing, like splash screens, system tray access, and table sorting and filtering and lots more. What you won't find in Java 6 Platform Revealed is a "getting started with Java" tutorial. Come prepared with a good working knowledge of Java 5 platform for best results.
Not only will you see what's in Java's future, but you'll learn how to actually use many of the new features of the platform quickly.
Table of Contents
* Java SE 6 at a Glance
* Language and Utility Updates
* I/O, Networking, and Security Updates
* AWT and Swing Updates
* JDBC 4.0
* Extensible Markup Language (XML)
* Web Services
* The Java Compiler API
* Scripting and JSR 223
* Pluggable Annotation Processing Updates
CONTENTS:
John Zukowski
Java 6 Platform
Revealed
Java 6 Platform Revealed
Copyright © 2006 by John Zukowski
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-660-9
ISBN-10 (pbk): 1-59059-660-9
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in the
US and other countries.
Apress, Inc. is not affiliated with Sun Microsystems, Inc., and this book was written without endorsement
from Sun Microsystems, Inc.
Lead Editor: Steve Anglin
Technical Reviewer: Sumit Pal
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick,
Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft,
Jim Sumser, Keir Thomas, Matt Wade
Project Manager: Kylie Johnston
Copy Edit Manager: Nicole LeClerc
Copy Editor: Damon Larson
Assistant Production Director: Kari Brooks-Copony
Production Editor: Laura Esterman
Compositor: Dina Quan
Proofreader: Elizabeth Berry
Indexer: Toma Mulligan
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or
visit http://www.springeronline.com.
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley,
CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http://www.apress.com.
The information in this book is distributed on an as is basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly
by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com in the Source Code section.
Contents
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
■CHAPTER 1 Java SE 6 at a Glance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Early Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
What's New? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
JavaBeans Activation Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Service Provider Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
■CHAPTER 2 Language and Utility Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
The java.lang Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
System.console() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Empty Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
The java.util Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Calendar Display Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Deques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Navigable Maps and Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Resource Bundle Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Array Copies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Lazy Atomics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
v
■CHAPTER 3 I/O, Networking, and Security Updates . . . . . . . . . . . . . . . . . . . 39
The java.io Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
The java.nio Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
The java.net Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
The java.security Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
■CHAPTER 4 AWT and Swing Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
The java.awt Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Splash Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
System Tray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Dialog Modality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
GIF Writer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Text Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Miscellaneous Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
The javax.swing Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Table Sorting and Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
The SwingWorker Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
JTabbedPane Component Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Text Component Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Drag-and-Drop Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
More Miscellaneous Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
■CHAPTER 5 JDBC 4.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
The java.sql and javax.sql Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Database Driver Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Exception Handling Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Enhanced BLOB/CLOB Functionality . . . . . . . . . . . . . . . . . . . . . . . . . 107
Connection and Statement Interface Enhancements . . . . . . . . . . . 108
National Character Set Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
SQL ROWID Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
SQL 2003 XML Data Type Support . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
■CONTENTS vi
■CHAPTER 6 Extensible Markup Language (XML) . . . . . . . . . . . . . . . . . . . . . 115
The javax.xml.bind Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
The javax.xml.crypto Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
The javax.xml.stream Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
■CHAPTER 7 Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
The javax.jws Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
The javax.xml.ws and javax.xml.soap Packages . . . . . . . . . . . . . . . . . . . 150
SOAP Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
The JAX-WS API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
■CHAPTER 8 The Java Compiler API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Compiling Source, Take 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Compiling Source, Take 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Introducing StandardJavaFileManager . . . . . . . . . . . . . . . . . . . . . . . 158
Working with DiagnosticListener . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Changing the Output Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Changing the Input Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Compiling from Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
■CHAPTER 9 Scripting and JSR 223 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Scripting Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
The Compilable Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
The Invocable Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
jrunscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Get Your Pnuts Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
■CONTENTS vii
■CHAPTER 10 Pluggable Annotation Processing Updates . . . . . . . . . . . . . . 183
JDK 5.0 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
The @Deprecated Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
The @SuppressWarnings Annotation . . . . . . . . . . . . . . . . . . . . . . . . 185
The @Override Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
JDK 6.0 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
New Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Annotation Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
■APPENDIX Licensing, Installation, and Participation . . . . . . . . . . . . . . . . 201
Snapshot Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Licensing Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Getting the Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Participation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
■CONTENTS viii
Published
Jul 2006
Publisher
APRESS
ISBN
9781590596609
Pages
220




Static Book Details Index Page - Click Here to go to Computer Manuals Website