Table Of Contents Part 1: Introducing Java - Allfree-stuff

Transcription

A Deskop Quick Reference (Java in a Nutshell: Java in a Nutshell)by David FlanaganISBN 1-56592-487-8EThird edition, published November 1999.(See the catalog page for this book.)Search the text of Java in a Nutshell: A Deskop Quick Reference.Table of ContentsCopyrightPrefacePart 1: Introducing JavaChapter 1: IntroductionChapter 2: Java Syntax from the Ground UpChapter 3: Object-Oriented Programming in JavaChapter 4: The Java PlatformChapter 5: Java SecurityChapter 6: JavaBeansChapter 7: Java Programming and Documentation ConventionsChapter 8: Java Development ToolsPart 2: API Quick ReferenceHow To Use This Quick ReferenceChapter 9: The java.beans PackageChapter 10: The java.beans.beancontext PackageChapter 11: The java.io PackageChapter 12: The java.lang PackageChapter 13: The java.lang.ref PackageChapter 14: The java.lang.reflect PackageChapter 15: The java.math Packagefile:///C /orielly/jnut/index.htm (1 of 2) [2/5/2003 7:45:15 PM]

A Deskop Quick Reference (Java in a Nutshell: Java in a Nutshell)Chapter 16: The java.net PackageChapter 17: The java.security PackageChapter 18: The java.security.acl PackageChapter 19: The java.security.cert PackageChapter 20: The java.security.interfaces PackageChapter 21: The java.security.spec PackageChapter 22: The java.text PackageChapter 23: The java.util PackageChapter 24: The java.util.jar PackageChapter 25: The java.util.zip PackageChapter 26: The javax.crypto PackageChapter 27: The javax.crypto.interfaces PackageChapter 28: The javax.crypto.spec PackageChapter 29: Class, Method, and Field IndexIndexColophonCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/index.htm (2 of 2) [2/5/2003 7:45:15 PM]

Preface (Java in a Nutshell)Java in a Nutshell: ADeskop Quick ReferencePrefaceThis book is a desktop quick reference for Java programmers, designed to sit faithfully by yourkeyboard while you program. Part 1, "Introducing Java" of the book is a fast-paced, "no-fluff"introduction to the Java programming language and the core APIs of the Java platform. Part 2, "APIQuick Reference" is a quick-reference section that succinctly details every class and interface of thosecore APIs. The book covers Versions 1.0, 1.1, 1.2, and 1.3 beta of Java.0.1. Changes Since the Second EditionReaders who are familiar with the second edition of this book will notice a number of changes in thisedition. Most notably, the AWT and applet APIs are no longer documented in this book. The Javaplatform tripled in size between Java 1.1 and Java 1.2. Accordingly, and unavoidably, Java in a Nutshellhas been split into three volumes. The volume you are now reading documents only the essential APIs ofthe platform, including the basic language and utility classes, as well as classes for input/output,networking, and security. See the Table of Contents for a complete list of the packages documented here.If you are a client-side programmer who is working with graphics or graphical user interfaces, you willprobably want to supplement this book with Java Foundation Classes in a Nutshell, which documents allthe graphics- and GUI-related classes, including the AWT, Swing, Java 2D, and applet APIs. And, if youare an server-side or enterprise programmer, you will likely be interested in Java Enterprise in aNutshell.Another big change is that Part 1, "Introducing Java" of this book has been almost entirely rewritten. Thefirst and second editions of this book assumed knowledge of and experience with C or C . Now thatJava has come thoroughly into its own, that assumption no longer seems appropriate, so I have rewrittenand expanded Chapters 2 and 3 to explain Java without any reference to C, C , or any otherprogramming language. Programmers with a modest amount of experience should now be able to learnJava programming from this book. These introductory chapters are written in a tight, concise style, soprogrammers who already know Java should find them useful as a language reference.Another new feature of Part 1, "Introducing Java" is Chapter 4, "The Java Platform". This chapter is anintroduction to the APIs documented in the reference section of the book. It includes more than 60file:///C /orielly/jnut/ch00 01.htm (1 of 2) [2/5/2003 7:45:25 PM]

Preface (Java in a Nutshell)detailed API usage examples that show how to accomplish common tasks with the predefined classes ofthe Java platform.Finally, the quick-reference section in Part 2, "API Quick Reference" of the book has a new look thatdramatically improves the readability of the reference material and packs even more API informationinto a small space. Even if you are already familiar with the second edition, you should take the time toread the "How To Use This Quick Reference" section at the beginning of Part 2, "API Quick Reference";it explains the new quick-reference format and shows you how to get the most out of it.CopyrightCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 01.htm (2 of 2) [2/5/2003 7:45:25 PM]0.2. Contents of This Book

Contents of This Book (Java in a Nutshell)Preface0.2. Contents of This BookThe first eight chapters of this book document the Java language, the Java platform, and the Javadevelopment tools that are supplied with Sun's Java SDK (software development kit):Chapter 1, "Introduction"This chapter is an overview of the Java language and the Java platform that explains the importantfeatures and benefits of Java. It concludes with an example Java program and walks the new Javaprogrammer through it line by line.Chapter 2, "Java Syntax from the Ground Up"This chapter explains the details of the Java programming language. It is a long and detailedchapter. Experienced Java programmers can use it as a language reference. Programmers withsubstantial experience with languages such as C and C should be able to pick up Java syntax byreading this chapter. The chapter does not assume years of programming experience, or evenfamiliarity, with C or C , however. Even beginning programmers, with only modest experience,should be able to learn Java programming by studying this chapter carefully.Chapter 3, "Object-Oriented Programming in Java"This chapter describes how the basic Java syntax documented in Chapter 2, "Java Syntax from theGround Up" is used to write object-oriented programs in Java. The chapter assumes no priorexperience with OO programming. It can be used as a tutorial by new programmers or as areference by experienced Java programmers.Chapter 4, "The Java Platform"This chapter is an overview of the essential Java APIs covered in this book. It contains numerousshort examples that demonstrate how to perform common tasks with the classes and interfacesthat comprise the Java platform. Programmers who are new to Java, and especially those wholearn best by example, should find this a valuable chapter.Chapter 5, "Java Security"file:///C /orielly/jnut/ch00 02.htm (1 of 2) [2/5/2003 7:45:33 PM]

Contents of This Book (Java in a Nutshell)This chapter explains the Java security architecture that allows untrusted code to run in a secureenvironment from which it cannot do any malicious damage to the host system. It is important forall Java programmers to have at least a passing familiarity with Java security mechanisms.Chapter 6, "JavaBeans"This chapter documents the JavaBeans component framework and explains what programmersneed to know to create and use the reusable, embeddable Java classes known as beans.Chapter 7, "Java Programming and Documentation Conventions"This chapter documents important and widely adopted Java programming conventions and alsoexplains how you can make your Java code self-documenting by including specially formatteddocumentation comments.Chapter 8, "Java Development Tools"The Java SDK shipped by Sun includes a number of useful Java development tools, most notablythe Java interpreter and the Java compiler. This chapter documents those tools.These first eight chapters teach you the Java language and get you up and running with the Java APIs.The bulk of the book, however, is the API quick reference, Chapters 9 through 29, which is a succinctbut detailed API reference formatted for optimum ease of use. Please be sure to read the How To UseThis Quick Reference section, which appears at the beginning of the reference section; it explains how toget the most out of this section.0.1. Changes Since theSecond EditionCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 02.htm (2 of 2) [2/5/2003 7:45:33 PM]0.3. Related Books

Related Books (Java in a Nutshell)Preface0.3. Related BooksO'Reilly & Associates, Inc. publishes an entire series of books on Java programming. These booksinclude Java Foundation Classes in a Nutshell and Java Enterprise in a Nutshell, which, as mentionedearlier, are companions to this book.A related reference work is the Java Power Reference. It is an electronic Java quick reference on CDROM that uses the Java in a Nutshell style. But since it is designed for viewing in a web browser, it isfully hyperlinked and includes a powerful search engine. It is wider in scope but narrower in depth thanthe Java in a Nutshell books. The Java Power Reference covers all the APIs of the Java 2 platform, plusthe APIs of many standard extensions. But it does not include tutorial chapters on the various APIs, nordoes it include descriptions of the individual classes.You can find a complete list of Java books from O'Reilly & Associates at http://java.oreilly.com/. Booksthat focus on the core Java APIs, as this one does, include:Exploring Java, by Pat Niemeyer and Joshua PeckA comprehensive tutorial introduction to Java, with an emphasis on client-side Javaprogramming.Java Threads, by Scott Oaks and Henry WongJava makes multithreaded programming easy, but doing it right can still be tricky. This bookexplains everything you need to know.Java I/O, by Elliotte Rusty HaroldJava's stream-based input/output architecture is a thing of beauty. This book covers it in the detailit deserves.Java Network Programming, by Elliotte Rusty HaroldThis book documents the Java networking APIs in detail.file:///C /orielly/jnut/ch00 03.htm (1 of 2) [2/5/2003 7:45:36 PM]

Related Books (Java in a Nutshell)Java Security, by Scott OaksThis book explains the Java access-control mechanisms in detail and also documents theauthentication mechanisms of digital signatures and message digests.Java Cryptography, by Jonathan KnudsenThorough coverage of the Java Cryptography Extension, the javax.crypto.* packages, andeverything you need to know about cryptography in Java.Developing Java Beans, by Robert EnglanderA complete guide to writing components that work with the JavaBeans API.0.2. Contents of This BookCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 03.htm (2 of 2) [2/5/2003 7:45:36 PM]0.4. Java ProgrammingResources Online

Java Programming Resources Online (Java in a Nutshell)Preface0.4. Java Programming Resources OnlineThis book is a quick reference designed for speedy access to frequently needed information. It does not,and cannot, tell you everything you need to know about Java. In addition to the books listed earlier, thereare several valuable (and free) electronic sources of information about Java programming.Sun's main web site for all things related to Java is http://java.sun.com/. The web site specifically forJava developers is http://developer.java.sun.com/. Much of the content on this developer site is passwordprotected, and access to it requires (free) registration.Sun distributes electronic documentation for all Java classes and methods in its javadoc HTML format.Although this documentation is somewhat difficult to navigate and is rough or outdated in places, it isstill an excellent starting point when you need to know more about a particular Java package, class,method, or field. If you do not already have the javadoc files with your Java distribution, seehttp://java.sun.com/docs/ for a link to the latest available version. Sun also distributes its excellent JavaTutorial online. You can browse and download it from http://java.sun.com/docs/books/tutorial/.For Usenet discussion (in English) about Java, try the comp.lang.java.programmer and relatedcomp.lang.java.* newsgroups. You can find the very comprehensive comp.lang.java.programmer FAQby Peter van der Linden at http://www.afu.com/javafaq.htm.Finally, don't forget O'Reilly's Java web site. http://java.oreilly.com/ contains Java news and commentaryand a monthly tips-and-tricks column by O'Reilly Java author Jonathan Knudsen.0.3. Related BooksCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 04.htm [2/5/2003 7:45:38 PM]0.5. Examples Online

Examples Online (Java in a Nutshell)Preface0.5. Examples OnlineThe examples in this book are available online and can be downloaded from the home page for the bookat http://www.oreilly.com/catalog/javanut3. You also may want to visit this site to see if any importantnotes or errata about the book have been published there.0.4. Java ProgrammingResources OnlineCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 05.htm [2/5/2003 7:45:41 PM]0.6. Conventions Used inThis Book

Conventions Used in This Book (Java in a Nutshell)Preface0.6. Conventions Used in This BookWe use the following formatting conventions in this book:ItalicUsed for emphasis and to signify the first use of a term. Italic is also used for commands, emailaddresses, web sites, FTP sites, file and directory names, and newsgroups.BoldOccasionally used to refer to particular keys on a computer keyboard or to portions of a userinterface, such as the Back button or the Options menu.Letter GothicUsed in all Java code and generally for anything that you would type literally when programming,including keywords, data types, constants, method names, variables, class names, and interfacenames.Letter Gothic ObliqueUsed for the names of function arguments and generally as a placeholder to indicate an item thatshould be replaced with an actual value in your program.Franklin Gothic Book CondensedUsed for the Java class synopses in the quick-reference section. This very narrow font allows us tofit a lot of information on the page without a lot of distracting line breaks. This font is also usedfor code entities in the descriptions in the quick-reference section.Franklin Gothic Demi CondensedUsed for highlighting class, method, field, property, and constructor names in the quick-referencesection, which makes it easier to scan the class synopses.file:///C /orielly/jnut/ch00 06.htm (1 of 2) [2/5/2003 7:45:43 PM]

Conventions Used in This Book (Java in a Nutshell)Franklin Gothic Book Compressed ItalicUsed for method parameter names and comments in the quick-reference section.0.5. Examples OnlineCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 06.htm (2 of 2) [2/5/2003 7:45:43 PM]0.7. Request for Comments

Request for Comments (Java in a Nutshell)Preface0.7. Request for CommentsPlease help us improve future editions of this book by reporting any errors, inaccuracies, bugs,misleading or confusing statements, and even plain old typos that you find. Please also let us know whatwe can do to make this book more useful to you. We take your comments seriously and will try toincorporate reasonable suggestions into future editions. You can contact us by writing:O'Reilly & Associates, Inc.101 Morris StreetSebastopol, CA 954721-800-998-9938 (in the United States or Canada)1-707-829-0515 (international/local)1-707-829-0104 (fax)You can also send us messages electronically. To be put on the mailing list or request a catalog, sendemail to:info@oreilly.comTo ask technical questions or comment on the book, send email to:bookquestions@oreilly.comWe have a web site for the book, where we'll list examples, errata, and any plans for future editions. Youcan access this page at:http://www.oreilly.com/catalog/javanut3/For more information about this book and others, see the O'Reilly web site:http://www.oreilly.comfile:///C /orielly/jnut/ch00 07.htm (1 of 2) [2/5/2003 7:45:46 PM]

Request for Comments (Java in a Nutshell)0.6. Conventions Used inThis BookCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 07.htm (2 of 2) [2/5/2003 7:45:46 PM]0.8. How the QuickReference Is Generated

How the Quick Reference Is Generated (Java in a Nutshell)Preface0.8. How the Quick Reference Is GeneratedFor the nerdy or merely inquisitive reader, this section explains a bit about how the quick-referencematerial in Java in a Nutshell and related books is created.As Java has evolved, so has my system for generating Java quick-reference material. The current systemis part of a larger commercial documentation browser system I'm developing (visithttp://www.davidflanagan.com/Jude/ for more information about it). The program works in two passes:the first pass collects and organizes the API information, and the second pass outputs that information inthe form of quick-reference chapters.The first pass begins by reading the class files for all of the classes and interfaces to be documented.Almost all of the API information in the quick reference is available in these class files. The notableexception is the names of method arguments, which are not stored in class files. These argument namesare obtained by parsing the Java source file for each class and interface. Where source files are notavailable, I obtain method argument names by parsing the API documentation generated by javadoc. Theparsers I use to extract API information from the source files and javadoc files are created using the Antlrparser generator developed by Terrence Parr of the Magelang Institute. (See http://www.antlr.org/ fordetails on this very powerful programming tool.)Once the API information has been obtained by reading class files, source files, and javadoc files, theprogram spends some time sorting and cross-referencing everything. Then it stores all the APIinformation into a single large data file.The second pass reads API information from that data file and outputs quick-reference chapters using acustom SGML format. The SGML markup is fairly complex, but the code that generates it is quitemundane. Once I've generated the SGML output, I hand it off to the production team at O'Reilly &Associates. They process it and convert it to troff source code. The troff source is processed with theGNU groff program (ftp://ftp.gnu.org/gnu/groff/ ) and a custom set of troff macros to produce PostScriptoutput that is shipped directly to the printer.0.7. Request for Commentsfile:///C /orielly/jnut/ch00 08.htm (1 of 2) [2/5/2003 7:45:49 PM]0.9. Acknowledgments

How the Quick Reference Is Generated (Java in a Nutshell)Copyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 08.htm (2 of 2) [2/5/2003 7:45:49 PM]

Acknowledgments (Java in a Nutshell)Preface0.9. AcknowledgmentsMany people helped in the creation of this book, and I am grateful to them all. I am indebted to the many,many readers of the first two editions who wrote in with comments, suggestions, bug reports, and praise.Their many small contributions are scattered throughout the book. Also, my apologies to those who madethe many good suggestions that could not be incorporated into this edition.Paula Ferguson, a friend and colleague, has been the editor of all three editions of this book. Her carefulreading and always-practical suggestions have made the book stronger, clearer, and more useful. Sheguided the evolution of Java in a Nutshell from a single book into a three-volume series and, at times,juggled editing tasks for all three books at once. Finally, Paula went above and beyond the call ofeditorial duty by designing the hierarchy diagrams found at the start of each reference chapter.Mike Loukides provided high-level direction and guidance for the first edition of the book. EricRaymond and Troy Downing reviewed that first edition--they helped spot my errors and omissions andoffered good advice on making the book more useful to Java programmers.For the second edition, John Zukowski reviewed my Java 1.1 AWT quick-reference material, and GeorgeReese reviewed most of the remaining new material. The second edition was also blessed with a "dreamteam" of technical reviewers from Sun. John Rose, the author of the Java inner class specification,reviewed the chapter on inner classes. Mark Reinhold, author of the new character stream classes injava.io, reviewed my documentation of these classes. Nakul Saraiya, the designer of the new JavaReflection API, reviewed my documentation of the java.lang.reflect package. I am very gratefulto these engineers and architects; their efforts made this a stronger, more accurate book.The third edition also benefited greatly from the contributions of reviewers who are intimately familiarwith the Java platform. Joshua Bloch, one of the primary authors of the Java collections framework,reviewed my descriptions of the collections classes and interfaces. Joshua was also helpful in discussingthe Timer and TimerTask classes of Java 1.3 with me. Mark Reinhold, creator of thejava.lang.ref package, explained the package to me and reviewed my documentation of it. ScottOaks reviewed my descriptions of the Java security and cryptography classes and interfaces. Joshua,Mark, and Scott are all engineers with Sun Microsystems, and I'm very grateful for their time. Thedocumentation of the javax.crypto package and its subpackages was also reviewed by Jon Eaves.Jon worked on a clean-room implementation of the Java Cryptography Extension (which is availablefrom http://www.aba.net.au/ ), and his comments were quite helpful. Jon now works for FluentTechnologies (http://www.fluent.com.au/ ) consulting in Java and electronic commerce. Finally, Chapterfile:///C /orielly/jnut/ch00 09.htm (1 of 2) [2/5/2003 7:45:52 PM]

Acknowledgments (Java in a Nutshell)1 was improved by the comments of reviewers who were not already familiar with the Java platform:Christina Byrne reviewed it from the standpoint of a novice programmer, and Judita Byrne of VirginiaPower offered her comments as a professional COBOL programmer.The O'Reilly & Associates production team has done its usual fine work of creating a book out of theelectronic files I submit. My thanks to them all. And a special thanks to Lenny Muellner and ChrisMaden, who worked overtime to implement the new and improved format of the quick-reference section.As always, my thanks and love to Christie.David Flanaganhttp://www.davidflanagan.com/September 19990.8. How the QuickReference Is GeneratedCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/ch00 09.htm (2 of 2) [2/5/2003 7:45:52 PM]Part 1. Introducing Java

Introducing Java (Java in a Nutshell)Java in a Nutshell: ADeskop Quick ReferencePart 1. Introducing JavaPart I is an introduction to the Java language and the Java platform. These chapters provide enoughinformation for you to get started using Java right away.0.9. AcknowledgmentsCopyright 2001 O'Reilly & Associates. All rights reserved.file:///C /orielly/jnut/part1.htm [2/5/2003 7:45:55 PM]1. Introduction

Introduction (Java in a Nutshell)Part 1: Introducing JavaChapter 1. IntroductionContents:What Is Java?Key Benefits of JavaAn Example ProgramWelcome to Java. Since its introduction in late 1995, the Java language and platform have taken theprogramming world by storm. This chapter begins by explaining what Java is and why it has become sopopular. Then, as a tutorial introduction to the language, it walks you through a simple Java program youcan type in, compile, and run.1.1. What Is Java?In discussing Java, it is important to distinguish between the Java programming language, the JavaVirtual Machine, and the Java platform. The Java programming language is the language in which Javaapplications (including applets, servlets, and JavaBeans components) are written. When a Java programis compiled, it is converted to byte codes that are the portable machine language of a CPU architectureknown as the Java Virtual Machine (also called the Java VM or JVM). The JVM can be implementeddirectly in hardware, but it is usually implemented in the form of a software program that interprets andexecutes byte codes.The Java platform is distinct from both the Java language and Java VM. The Java platform is thepredefined set of Java classes that exist on every Java installation; these classes are available for use byall Java programs. The Java platform is also sometimes referred to as the Java runtime environment orthe core Java APIs (application programming interfaces). The Java platform can be extended withoptional standard extensions. These extension APIs exist in some Java installations, but are notguaranteed to exist in all installations.1.1.1. The Java Programming LanguageThe Java programming language is a state-of-the-art, object-oriented language that has a syntax similarto that of C. The language designers strove to make the Java language powerful, but, at the same time,file:///C /orielly/jnut/ch01 01.htm (1 of 4) [2/5/2003 7:45:57 PM]

Introduction (Java in a Nutshell)they tried to avoid the overly complex features that have bogged down other object-oriented languages,such as C . By keeping the language simple, the designers also made it easier for programmers to writerobust, bug-free code. As a result of its elegant design and next-generation features, the Java languagehas proved wildly popular with programmers, who typically find it a pleasure to work with Java afterstruggling with more difficult, less powerful languages.1.1.2. The Java Virtual MachineThe Java Virtual Machine, or Java interpreter, is the crucial piece of every Java installation. By design,Java programs are portable, but they are only portable to platforms to which a Java interpreter has beenported. Sun ships VM implementations for its own Solaris operating system and for Microsoft Windows(95/98/NT) platforms. Many other vendors, including Apple and various Unix vendors, provide Javainterpreters for their platforms. There is a freely available port of Sun's VM for Linux platforms, andthere are also other third-party VM implementations available. The Java VM is not only for desktopsystems, however. It has been ported to set-top boxes, and versions are even available for hand-helddevices that run Windows CE and PalmOS.Although interpreters are not typically considered high-performance systems, Java VM performance isremarkably good and has been improving steadily. Of particular note is a VM technology called just-intime ( JIT) compilation, whereby Java byte codes are converted on-the-fly into native-platform machinelanguage, boosting execution speed for code that is run repeatedly. Sun's new Hotspot technology is aparticularly good implementation of JIT compilation.1.1.3. The Java PlatformThe Java platform is just as important as the Java programming language and the Java Virtual Machine.All programs written in the Java language rely on the set of predefined classes[1] that comprise the Javaplatform. Java classes are organized into related groups known as packages. The Java platform definespackages for functionality such as input/output, networking, graphics, user-interface creation, security,and much more.[1]A class is a module of Java code that defines a data structure and a set of methods (alsocalled procedures, functions, or subroutines) that operate on that data.The Java 1.2 release was a major milestone for the Java platform. This release almost tripled the numberof classes in the platform and introduced significant new functionality. In recognition of this, Sun namedthe new version the Java 2 Platform. This is a trademarked name created for marketing purposes; itserves to emphasize how much Java has grown since its first release. However, most programmers referto the Java platform by its official version number, which, at the time of this writing, is 1.2.[2][2]Although there is currently a beta release of Java 1.3 availablefile:///C /orielly/jnut/ch01 01.htm (2 of 4) [2/5/2003 7:45:57 PM]

Introduction (Java in a Nutshell)It is important to understand what is meant by the term platform. To a computer programmer, a platformis defined by the APIs he or she can rely on when writing programs. These APIs are usually defined bythe operating system of the target computer. Thus, a programmer writing a program to run underMicrosoft Windows must use a different set of APIs than a programmer writing the same program for theMacintosh or for a Unix-based system. In this respect, Windows, Macintosh, and Unix are three distinctplatforms.Java is not an operating system.[3] Nevertheless, the Java platform--particularly the Java 2 Platform-provides APIs with a comparable breadth and depth to those defined by an operating system. With theJava 2 Platform, you can write applications in Java without sacrificing the advanced features available toprogrammers writing native applications targeted at a particular underlying operating system. Anapplication written on the Java platform runs on any operating system that supports the Java platform.This means you do not have to create distinct Windows, Macintosh, and Unix versions of your programs,for example. A single Java program runs on all these operating systems, which explains why "Writeonce, run anywhere" is Sun's motto for Java.[3]There is a Java-based operating system, however; it is known as JavaOS.It also explains why companies like Microsoft might feel threatened by Java. The Java platform is not anoperating system, but for programmers, it is an alternative development target and a very popular one atthat. The Java platform reduces programmers' reliance on the underlying operating s

Related Books (Java in a Nutshell) Preface 0.3. Related Books O'Reilly & Associates, Inc. publishes an entire series of books on Java programming. These books include Java Foundation Classes in a Nutshell and Java Enterprise in a Nutshell, which, as mentioned earlier, are companions to this book. A related reference work is the Java Power .