Home > Store

Just Java 2, 4th Edition

Register your product to gain access to bonus material or receive a coupon.

Just Java 2, 4th Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 1999
  • Edition: 4th
  • Book
  • ISBN-10: 0-13-010534-1
  • ISBN-13: 978-0-13-010534-9


1053D-6

If you are looking for a readable, up-to-date overview of the JDK and its libraries, Just Java 2, Fourth Edition is the book for you! You'll find an engaging tutorial complete with clear explanations and challenging examples, and just the right mix of comic relief. Peter van der Linden, the author of the classic Expert C Programming, brings style, personality, and wit to the challenge of simplifying Java and object-oriented programming for any programmer making the transition to the Java environment.

Because Just Java 2 assumes some programming knowledge, you won't get bogged down with the basics. A unique balance of practical advice and expert insights, this comprehensive guide to Java programming covers all the essentials including:

  • Object-Oriented techniques.
  • Types & arrays.
  • Statements & exceptions.
  • Swing components & containers.
  • Networking & client-server.
  • Threads and more.

This revised and expanded edition includes a concise introduction to the new features and libraries, especially inner classes and the graphical "Swing" components and highlights both the advantages and challenges of programming with Java 2.

The accompanying CD-ROM is a truly awesome resource! It contains extensive sample code from top Java programmers, the complete Java Programmer's FAQ, and tons of great freeware, including Linux, Perl, GNU C/C++, Tcl, Python, Java games (with source code, and more)! Due to an unfortunate error in the manufacturing process of the CD-ROM, a number of defective or cracked CDs were shipped with this book. Prentice Hall PTR will be happy to send you a replacement CD-ROM, which can be obtained by emailing disc_exchange@prenhall.com

Sample Content

Table of Contents

1. What Is Java.
Compiling and Executing a Sample Program. The Biggest Java Benefit: Portability. The “Java Platform” . The Java Language. Java Libraries. Releases of the JDK to Date. Java Virtual Machine. The World Wide Web and Java.

2. The Story of O: Object-Oriented Programming.
Abstraction. Encapsulation. The One-Minute Object Manager. Classes. Per-Instance and Per-Class Members. The “final” Modifier. Access Modifiers. Some Light Relief.

3. Explanation of a Sample Program.
Explanation of the Example Program. Where an Application Starts. Runtime Internals: Stack and Heap. The Class “Object” . Some Light Relief.

4. Identifiers, Keywords, and Types.
Identifiers. Comments. Keywords. The Primitive Types. Some Light Relief.

5. Names, Arrays, Operators, and Accuracy.
Names. Expressions. Arrays. Operators. Associativity. How Accurate Are Calculations? What Happens on Overflow? The Math Package. Some Light Relief. Further Reading.

6. More OOP —Extending Classes.
Inheritance. Polymorphism. The Class Whose Name Is Class. Some Light Relief. Exercises.

7. Java Statements.
“Organizing” Statements. Expression Statements. Selection Statements. Iteration Statements. Transfer of Control Statements. Exceptions. Some Light Relief.

8. Interfaces.
Using Interfaces Dynamically. Some Light Relief. Exercises.

9. Packages and Visibility.
How Packages Support Namespaces. Compilation Units. Inner Classes. The Class Character. Some Light Relief.

10. Doing Several Things at Once: Threads.
What Are Threads? Two Ways to Obtain a New Thread. The Lifecycle of a Thread. Thread Groups. Four Kinds of Threads Programming. Some Light Relief.

11. Advanced Thread Topics.
Swing Threads—A Caution! Garbage Collection. Some Light Relief. Exercises. Further Reading.

12. Practical Examples Explained.
Case Study Java Program: Fritter Engine Shunt. Some Light Relief. Exercises.

13. All About Applets.
Embedding a Java Program in a Web Page. Starting Applet Execution. Zip Files and Jar Files. Some Light Relief. Further References. HTML Applet Tags. Exercises.

14. JDK 1.2 Security.
The Sandbox. Code Signing. The Security Manager. Applying the Security Policy. Signing a Java Program. Some Light Relief. Further References.

15. Java Data Structures Library.
The java.math API. The java.util API. Collections. Calendar Utilities. Other Utilities. Some Light Relief. Exercises.

16. Java Enterprise Libraries.
Object Communication Middleware. Remote Method Invocation. Object Serialization. Java and Databases: JDBC. Useful URLs. Some Light Relief.

17. GUI Basics and Event-Handling.
All About Event-Handling. Tips for Slimming down Handler Code. Summary of Event-Handling. Some Light Relief.

18. JFC and the Swing Package.
Java Foundation Classes. All About Controls (JComponents). More about Swing Components. Some Light Relief.

19. Containers, Layouts, and AWT Loose Ends.
Pluggable Look and Feel. All About Containers. Layout in a Container. Tying up the Loose Ends. Some Light Relief.

20. Graphics Programming.
Colors. Fonts and Font Metrics. The Graphics Context. Drawing Text, Lines, and Shapes. Loading and Drawing Images. Sounds. Some Light Relief.

21. File I/O.
Files and Streams. Formats, Encodings, and I/O. JDK 1.1 Input. JDK 1.1 Output. Piped I/O for Threads. How to Execute a Program from Java. ZIP Files and Streams. Some Light Relief. Answer To Programming Challenge. Answer To Programming Challenge.

22. Networking in Java.
Everything You Need To Know about TCP/IP But Failed to Learn in Kindergarten. Ping in Java. Sending E-Mail by Java. How to Make an Applet Write a File on the Server. HTTP and Web Browsing: Retrieving HTTP Pages. A Client/Server Socket Program. A Multi-Threaded Client/Server System. Page Counters in Web Pages. Some Light Relief. Exercises. Further Reading. Acknowledgments.

Appendix A: The Obsolete JDK 1.0 Event Model.
Obtaining Mouse and Keyboard Input. Capturing Individual KeyPresses. Handling the Quit Event.

Appendix B: Obsolete Components of the Abstract Window Toolkit.
How the Java Abstract Window Toolkit Works. Controls, Containers, Events. All About AWT Controls (Components). All About Containers.

Appendix C: Powers of 2 and ISO 8859.
Index.

Preface

Using the Just Java CD-ROM

About the CD-ROM

Welcome to the Just Java CD-ROM--a disk packed with all the Java tools and source code discussed in the book and lots more.

This CD is for any system that can read an ISO 9660 CD with the Rockridge/Joliet extensions (i.e., a system that can handle CDs with deep directories, symbolic links, and more than just 8.3 filenames, on Unix, Windows, and the Macintosh).

There is a huge amount of useful, entertaining, or educational material on this CD. Some of the content (and there is a lot more) is:

  • UsefulJava Development Kits for Windows, Macintosh, and Solaris.
    Java Programmer`s FAQ and Glossary.
    Decompilers and obfuscators.
  • EducationalTranslators for Perl, TCL, Eiffel, C, C++, Python, etc.
    CIA World Fact Book--your tax dollars at work.
    The Linux operating system for x86 (Debian 2.0 release).
  • EntertainingJava program to solve crossword puzzles.
    Java Digital Simulator.
    The Sherlock Holmes books.
    Java Bible Code software. Look for hidden messages.

You can explore the CD-ROM quite effectively using a browser. Mount the CD on your computer, and point your browser at the index.html file in the root.

 

You'll see a display like that shown above. Notice the three frames.

  • The top frame is a list of directories in this directory, plus a short description of each. You can click on a directory name to move the browser into that directory. That's what the arrow above shows.
  • The left-hand frame is a list of useful files in this directory. You can click on a filename to display that file in the right-hand frame.
  • The right-hand frame is an area for displaying files. Sometimes an applet runs in that frame, as shown in the figure above.

You can drag the frame boundaries around if it helps you to read the contents. If you click on, for example, the "goodies" directory name indicated by the arrow in the previous diagram, the browser will take you to that directory, and the display will now look like this:

You can carry on exploring this way. You can also use the "back" and "forward" buttons in the browser if you want. There are hundreds of megabytes of data of interest to a professional programmer on this CD, including many freeware or shareware compilers for other programming languages.

Before you tackle the other languages, you'll want to install and try Java as explained in the following pages. Choose the latest (highest version number) JDK for your system, and check for a more recent one on the web.

Using the CD-ROM on Windows 95, 98, and NT

Installing the JDK on Windows 95, 98, or NT:

  1. Put the CD in the CD drive, and in a shelltool go to the directory win95NT.

d:\win95NT

Your CD drive letter may be d: or e: or something else. You need around 65MB of disk space for the release.

  1. Choose the highest version number release. If there is a more recent one at http://java.sun.com, download and use that instead. Execute the self-extracting archive.

jdk12-win32

This will ask you a couple of questions and install the Java compiler and tools. A good place to install the compiler is in c:\jdk1.2.

  1. Once the JDK files have been unpacked onto your hard drive, you will need to add (or modify) the PATH variable in your autoexec.bat file. Use a text editor to add the jdk1.2\bin directory to your path:

SET PATH=c:\jdk1.2\bin; (...the rest of your path)

  1. Save the change to your autoexec.bat and restart your computer so the new variable takes effect. Earlier versions of the JDK required you to set an additional variable, CLASSPATH. From JDK 1.2 this is needed only if there are user classes outside your current directory. For now, ignore this shell variable.
  2. There is a file called "docs/install.html" in the JDK directory. It contains a longer explanation of installation, along with a troubleshooting guide. Please refer to it as necessary.

This CD-ROM does not have a Java compiler for Windows 3.1. A Windows 3.1 version of Java can be downloaded from http://www.alphaworks.ibm.com/formula, but I don't recommend it. Win3.1 and typical Win3.1 hardware lack too many features to be truly satisfactory.

Note: Many of the files on this CD use long file names, which is one of the features of Windows 95. If you are unable to see the long file names on the CD, your Windows 95/NT system may not be configured correctly. Check by double-clicking on the "System" icon in the Control Panel and then clicking on the "Performance" tab. If the "Performance" section does not indicate that "Your system is configured for optimal performance," then there is a configuration issue. See Windows Help or contact Microsoft Technical Support for further assistance.

Using the CD-ROM on Macintosh

Installing the JDK on a Macintosh:

Apple's Java, bundled with Mac OS 8.1 and later, only has the runtime library, not the compiler. So you'll need to install it from this CD. Apple (one of the companies with the most to gain from portable software) is regrettably not current with the latest Java. So the JDK 1.2 libraries described in this text won't yet run on your Macintosh. If you'd like to see an up-to-date version of Java on Apple's computers, be sure to let Apple know about it by letter, phone call, or e-mail.

Apple Java Releases

Java Release

Apple Name

Works on Mac OS

JDK 1.0.2

MRJ 1.0

Mac OS 7.5.3 rev 2 or later

JDK 1.1.3

MRJ 2.0

Mac OS 8.0 or later; Mac OS 7.6.1 or later with custom install

JDK 1.2

Not avail, Nov. 1998

N/A

  1. Put the CD in the CD drive, and review the directory called "mac." Look at the highest version number JDK there, e.g., JDK 1-0-2. As this book went to press, I was still waiting for Apple's permission to bundle the compiler.
  2. Then use a browser to look at the following:

http://www.apple.com/macos/java/

Choose the highest version number release from the CD and the Apple site. Download the self-mounting image to your hard drive and double-click to open. You need around 30MB of disk space for the release.

  1. The Apple Java compiler currently consists of two files, MRJSDK2.0.1.bin and MRJ_2.0.smi.bin, both of which need to be installed. Do the usual clicking to expand them. You can compile and run Java programs by dragging and dropping the appropriate files onto the Java tools javac and JBindery.

Note: You should note that Macintosh, Windows, and Unix text files have different conventions for end-of-line. Macintosh expects a carriage return, Windows expects a carriage return and a linefeed, and UNIX expects a newline character (linefeed). Even though some text files may not appear to be properly formatted, the Java compiler handles source files created under any of these conventions.

You should also note that file names longer than twenty-six characters will be truncated on a Mac. Therefore, some of the sample Java programs on this CD will have to be renamed and recompiled to execute properly on a Macintosh.

Using the CD-ROM on Solaris

Installing the JDK (Solaris 2.5.1 or Later):

This CD uses the Rockridge extensions, so Solaris users may get a warning message saying the CD doesn't conform to the ISO 9660 specification. Ignore it.

The solaris.sparc directory contains the JDK for Sparc. The solaris.x86 directory contains the Intel version. Installation instructions are the same for Solaris for SPARC and Solaris for x86. On Intel systems, use "x86" instead of "sparc" in the filenames below. Insert the Just Java CD into your CD-ROM drive.

  1. If Volume Manager is running on your machine, the CD is automatically mounted to the /cdrom/just_java directory when you insert it. If the Volume Manager is not running on your machine, mount the CD manually by becoming root and typing:

# mkdir -p /cdrom/just_java

# mount -rF hsfs /dev/dsk/c0t6d0s0 /cdrom/just_java

  1. Choose the highest version number release. If there is a more recent one at http://www.sun.com, download and use that instead. Copy the file to your hard disk. Assume you're putting it in /home/linden, it would go here:

cd /cdrom/just_java/solaris.sparc

cp jdk1.2-solaris2-sparc.bin /home/linden

This is about a 20MB file, so it will take a few seconds to copy.

  1. Execute the self-extracting archive, e.g.:

cd /home/linden

./jdk1.2-solaris2-sparc.bin

This will ask a couple of questions and install the Java compiler/tools.

  1. Add the java "bin" directory to your path. The exact filename and syntax depends on the shell you are using. If you are a C shell user, the file is .cshrc and the syntax is as shown:

setenv JAVAHOME /home/linden/jdk1.2

set path=( $JAVAHOME/bin ... rest of path ... )

Log out then log in so the new variables take effect.

Earlier versions of the JDK required you to set an additional variable, CLASSPATH. From JDK 1.2 this is needed only if you are trying to run user classes outside your current directory. For now, ignore this shell variable.

  1. There is a file called "docs/install.html" in the JDK directory. It contains a longer explanation of installation along with a troubleshooting guide. Please refer to it as necessary.
  2. Pathnames Used Throughout This Book

    The source code for the Java runtime library is part of the JDK that you have on this CD. From time to time, I will refer you to particular files.

    The first part of the pathname will depend on where you installed JDK, and I'll represent this by "$JAVAHOME."

    The separators in a pathname are different on Unix than on Windows. For example, I may recommend you look at a file located here:

    $JAVAHOME/src/java/awt/Windows.java

    If you installed Java on your PC at C:\jdk1.2fcs, then the file to review is here:

    C:\jdk1.2fcs\src\java\awt\Window.java.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020