Register your product to gain access to bonus material or receive a coupon.
Java programming language. Written by two members of the JavaSoft team at Sun Microsystems, the book employs a hands-on interactive approach to teaching Java basics, object-oriented concepts, applet programming, and everything else you need to know to become a proficient Java programmer.
Through a task-oriented, example-driven approach, The Java Tutorial introduces you to fundamental concepts and applications. Designed so that you can customize your own path through the specific information you need, the book explains the nuts and bolts of the language, applet construction, and the fundamental Java classes. You will also learn about more advanced topics such as creating a graphical user interface (GUI), using multiple threads, and working with Java's networking capabilities.
This Second Edition has been extensively updated to cover API changes in Java 1.1 regarding UI, networking, and I/O, and to include the latest Java language developments. New and updated material includes:
The accompanying CD-ROM contains the Tutorial and all its code samples, versions of the Java Development Kit (JDK) and the JDK documentation for each major platform, and the HotJava Browser. On the CD, the HTML version of the book is browser-friendly and contains information not found in the printed text, such as draft lessons on internationalizing Java programs, calling non-Java libraries from Java programs, using the security API, developing JavaBeans components, and using the GUI components in the Swing/JFC package.
Third Edition now available! |
Follow your own path to expertise with this self-guided tour of the Java™ programming language. Written by two members of the JavaSoft team at Sun Microsystems, the book employs a hands-on interactive approach to teaching Java basics, object-oriented concepts, applet programming, and everything else you need to know to become a proficient Java programmer.
Through a task-oriented, example-driven approach, The Java™ Tutorial introduces you to fundamental concepts and applications. Designed so that you can customize your own path through the specific information you need, the book explains the nuts and bolts of the language, applet construction, and the fundamental Java classes. You will also learn about more advanced topics such as creating a graphical user interface (GUI), using multiple threads, and working with Java's networking capabilities.
This Second Edition has been extensively updated to cover API changes in Java 1.1 regarding UI, networking, and I/O, and to include the latest Java language developments. New and updated material includes:
In addition, the Second Edition has been revised and reorganized to offer a stronger and more cohesive presentation, making this best-selling and award-winning book even better. The Tutorial now starts with a new lesson that introduces you to the Java phenomenon and provides a foundation for understanding the rest of the book.
The accompanying CD-ROM contains the Tutorial and all its code samples, versions of the Java Development Kit™ (JDK) and the JDK documentation for each major platform, and the HotJava™ Browser. On the CD, the HTML version of the book is browser-friendly and contains information not found in the printed text, such as draft lessons on internationalizing Java programs, calling non-Java libraries from Java programs, using the security API, developing JavaBeans™ components, and using the GUI components in the Swing/JFC package.
Lesson 1. The Java Phenomenon.
Lesson 2. The "Hello World" Application.
Lesson 3. The "Hello World" Applet.
Common Problems (and Their Solutions). End of Trail. Learning the Java Language.
Common Problems (and Their Solutions). End of Trail. Writing Applets.
Common Problems (and Their Solutions). End of Trail. Essential Java Classes.
End of Trail. Creating a User Interface.
Common Problems (and Their Solutions). End of Trail. Custom Networking.
End of Trail. To 1.1--And Beyond!
End of Trail.
Since the release of the JDK 1.0.2 in May of 1996, the Java engineering team has been hard at work improving and enhancing the Java platform. We have been similarly laboring to update The Java Tutorial to reflect the work of the engineers. From the first page to the last, this edition now documents the APIs in JDK 1.1. We have fully integrated JDK 1.1 updates into the text, plus we've added coverage of some of the new features of 1.1 such as the new AWT event model, object serialization, and inner classes. We also added a new trail to the end of the book that provides a summary of what changed for 1.1, information to help you decide when to convert 1.0 programs to 1.1, and instructions about how to perform the conversion. And finally we've included a preview of what's likely to come in the next major release of the JDK.
Yet, this edition of The Java Tutorial is more than just an update of the previous edition. It's more polished and mature. We have rewritten, clarified, and reorganized many areas of the book based on feedback from readers and reviewers.
Like the first edition, this book is based on the online tutorial hosted at the Java Web site.
http://java.sun.com/docs/books/tutorial/index.html
The first draft of the online tutorial was made available in May 1995. At that time, it contained a few basic lessons on writing applets, the fundamentals of the language itself, and some key classes. Since then, the tutorial has grown to over 10MB of HMTL files, images, and running programs. It contains dozens of lessons covering topics ranging from applet communication to security, from internationalization to JavaBeansTM. We are constantly updating the online version of the tutorial to cover new APIs developed by the engineering team.
Like the online version, this book reflects the latest Java advances. However, unlike the online version, page count limits what this book can cover. Hence, it focuses on the Java APIs needed by most beginning to intermediate Java programmers. If you don't find information in this book about part of the Java platform, check our Web site for it.
From the online tutorial to the first edition, and from the first edition to the second, our intent has always been to create a fun, easy-to-read, task-oriented programmer's guide with lots of practical examples to help people learn to program in Java.
This tutorial assumes that you have some programming experience, whether it be traditional procedural programming or object-oriented programming, and are familiar with programming tenets and terminology and at least one high-level language.
All Java programmers--novice and experienced alike--can benefit from this book. The first section begins with an overview of the Java platform and what it can help you do. It then presents two Java programs--one application and one applet--and shows you how to compile and run both. Finally, it describes how they work.
From this hands-on beginning, you can follow your own course of learning:
No matter what type of programmer you are, you can find a path through this book that fits your learning requirements.
This book documents the JDK 1.1 release of the Java platform. To compile and run the examples in this book you need a development environment that is compatible with JDK 1.1. You can use a commercially-available Java development environment or you can use the JDK itself.
You can use the version of JDK 1.1 that's on the CD-ROM accompanying this book. Or you might want to visit the Java Web side to download the latest version of the JDK:
http://java.sun.com/products/jdk/1.1/
If you are using the JDK provided by Sun Microsystems you will need one of the following systems:
If you are developing applets, you will need a browser that supports the 1.1 API. For testing applets, you can use a special limited browser called the Applet Viewer that ships with the JDK. For information about the browsers that are currently available and support 1.1, see the Web page for this book:
http://java.sun.com/docs/books/tutorial/2e/book.html
Finally, you need an editor that can save files in ASCII format with a .java extension. Also, the editor must allow you to specify both uppercase and lowercase letters in the filename.
Many Internet readers have helped us maintain and improve the quality of the tutorial by sending us e-mail and cheerfully pointing out our numerous typos, broken links, and more importantly, areas of the tutorial that caused confusion or could benefit from rewriting.
Many members of the Java engineering and documentation team have given us counsel, answered our many questions, reviewed our material, and even made contributions to it. They also make JavaSoft a fun place to work. The list is long but we'd particularly like to note the contributions of Brian Beck, Joshua Bloch, David Connelly, Chris Darke, Bill Foote, Carol Hayes, Herb Jellinek, Doug Kramer, Marianne Mueller, Marla Parker, Mark Reinhold, John Rose, John Wegis, and Beth Whitman. Kathy would like to thank all the members of the Swing engineering team for being such a great group to work with. And, notably, Ron Mandel, who kept our Macs and PCs operating in a mostly Sun environment.
We are grateful for the other writers at Sun who have contributed to the online tutorial as guest authors. So far this list of professional and talented writers includes Mary Dageforde, Andy Quinn, Beth Stearns, and Greg Voss.
The Java language wouldn't exist without its creator, James Gosling. We'd like to thank James, not only for creating the language but also for staying involved as the Java platform develops. On a personal note, we'd like to thank him for accepting an award for us from JavaWorld (who named the tutorial as one of three finalists in the Best Training Aid category).
Our team managers, Lisa Friendly, Rick Levenson, and Stans Kleijnen, create a work environment that lets us get our job done. We especially appreciate their support of flexible, if a bit unusual, work arrangements.
Mike Hendrickson, our editorial advisor at Addison-Wesley, is always a calming influence and keeps us on schedule. Sarah Weaver was the production manager on the book and Laura Michaels was our copy editor and grammar queen. The whole team at Addison-Wesley have been a pleasure to work with and continually strive for excellence on this and the other books in the series.
Our heartfelt appreciation goes to the newest member of the tutorial team, Alison Huml, who calmly and professionally managed this edition of the book. She managed our schedule, handled the relationship with the copy editor, incorporated copy edits, drew or fixed many diagrams and images in the book, and handled all of the PC and Mac file conversions--all within the first month of working with us. Alison provides us with a fresh perspective and renewed energy. We look forward to her contributions to future book projects and to the online version of the tutorial.
Of course, the Java team made everything possible by creating Java in the first place. But many individuals contributed to getting this book out the door.
A million thanks go to the Java team members who answered questions, reviewed material, and in some cases, contributed examples--all of this in the face of tight deadlines: Thomas Ball, Brenda Bowden, David Brown, Patrick Chan, Tom Chavez, David Connelly, Pavani Diwanji, Amy Fowler, Jim Graham, Herb Jellinek, Jonni Kanerva, Doug Kramer, Eugene Kuerner, Tim Lindholm, Ron Mandel, Henry McGilton, Marianne Mueller, Scott Rautmann, Benjamin Renaud, Hassan Schroeder, Richard Scorer, Sami Shaio, Arthur van Hoff, Frank Yellin, and Steve Zellers.
Painful though they may have been, the feedback our reviewers provided us was invaluable. These reviewers were Mike Ballantyne, Richard Campione, Lee Collins, Greg Crisp, Matt Fahrner, Murali Ghanta, Bill Harts, Eileen Head, Murali Murugan, Roberto Quijalvo, Philip Resnik, Roger Riggs, Roman Rorat, Neil Sundaresan, Michael Weiss, the ones who preferred to remain anonymous, and all of the Internet readers who were kind enough to take the time to send us e-mail to let us know of problem areas.
Chris Warth spent several weeks writing scripts and filters to convert our complex web of HTML pages into MIF format. He was most patient with us despite our demands and changes. Marsh Chamberlain designed and created our trail icons, and Jan Kaerrman provided us with the html2ps script, which we used to create PostScript files from HTML and print our first review copy of the manuscript. Nathan Walrath created the figure in the Trail Map section. When we both went on maternity leave after giving the book to Addison-Wesley, Randy Nelson served as our backup, taking care of the CD-ROM and the Web site for the tutorial.
The staff at Addison-Wesley--Mike Hendrickson, Katie Duffy, Pamela Yee, and Marty Rabinowitz--were professional, competent, and courteous throughout the development of this book and provided us with guidance, encouragement, and instruction. They also managed the practical things like copy editing, page design, graphics, and reviewers so that all we had to do was worry about content.
Lisa Friendly, the Java Series editor, our manager, and our friend, made this book possible by suggesting that we turn the online tutorial into a book. She kept us calm, reassured us often, and managed everything, from our relationship with Addison-Wesley to consistency with other books in the series. Without her encouragement and hard work, this tutorial would not exist.
Mary: This book is dedicated to my husband, Richard Campione, for being my greatest friend. It's also dedicated to Sophia, a delightful child and a constant reminder of what's truly important.
Kathy: This book is dedicated to my husband, Nathan Walrath, and to our children, Laine and Cosmo. Nathan has done whatever it takes to help me write this book, from distracting kids to dispensing advice and art criticism. Laine and Cosmo are not old enough to help--quite the opposite--but like their dad, they sure are fun.