ISBN-10:
0201707209
ISBN-13:
9780201707205
Pub. Date:
05/01/2000
Publisher:
Pearson Education
Essentials of the Java(TM) Programming Language : A Hands-On Guide / Edition 1

Essentials of the Java(TM) Programming Language : A Hands-On Guide / Edition 1

by Monica Pawlan

Paperback

Current price is , Original price is $34.95. You

Temporarily Out of Stock Online

Please check back later for updated availability.

Item is available through our marketplace sellers.

Product Details

ISBN-13: 9780201707205
Publisher: Pearson Education
Publication date: 05/01/2000
Pages: 320
Product dimensions: 7.41(w) x 9.23(h) x 0.63(d)

About the Author


Monica Pawlan is a staff writer for Sun Microsystems' Java Developer Connections"" (JDC). She is also a contributor to The Java" Tutorial Continued (Addison-Wesley, 1999). Monica has a back- ground in 2D and 3D graphics, security, and database products. She enjoys writing for developers and exploring the latest features of the Java programming language.

Read an Excerpt

PREFACE:

If you are new to programming in the Java™ language and have some experience with other languages, this tutorial could be for you. It walks you through how to use the Java 2 Platform software to develop a basic network application that uses common Java 2 platform features. This tutorial is not comprehensive, but instead it takes you on a straight and uncomplicated path through the more common features available in the Java platform. This tutorial is a learning tool and should be viewed as a stepping-stone for persons who find the currently available materials a little too overwhelming to start with.

To reduce your learning curve, this tutorial begins with a simple program in Lesson 1, develops the program by adding new features in every lesson, and leaves you with a general electronic commerce application and a basic understanding of object-oriented programming concepts in Lesson 15. Unlike other, more reference-style texts that give you a lot of definitions and concepts at the beginning, this tutorial takes a practical approach. New features and concepts are described when they are added to the example application, and the end of each lesson points to texts where you can get more information.

Please note the final application is for instructional purposes only and would need more work to make it production worthy. By the time you finish this tutorial, you should have enough knowledge to go on comfortably to other Java programming language learning materials currently on the market and continue your studies.

If you have no programming experience at all, you might still find this tutorial helpful; but you also might want to take anintroductory programming course before you proceed.

Lessons 1 through 8 explain how applications, applets, and servlets/JavaServer Pages™ are similar and different, how to build a basic user interface that handles simple user input, how to read data from and write data to files and databases, and how to send and receive data over the network.

Lessons 9 through 15 are somewhat more complex and build on the material presented in the first eight lessons. These lessons walk you through socket communications, building a user interface using more components, grouping multiple data elements as one unit (collections), saving data between program invocations (serialization), and internationalizing a program. Lesson 15 concludes the series with basic object-oriented programming concepts.

This tutorial covers object-oriented concepts at the end, after you have had practical experience with the language so you can relate the object-oriented concepts to your experiences. This should make learning the concepts a little easier. Remember, this tutorial is a learning tool, and the intention is that you gain enough experience and information here to go on comfortably to other more comprehensive and in-depth texts to continue your studies.

Appendix A provides a version of the enterprise example that uses encryption and decryption technology to pass a credit card number over the network. This material is in an appendix because the encryption and decryption software is currently available only in the United States and Canada.

Appendix B presents the complete and final code for this tutorial.

Note: JavaBeans™ technology, which lets you create portable program components that follow simple naming and design conventions, is not covered here. While creating a simple JavaBean component is easy, understanding JavaBeans features requires knowledge of such things as properties, serialization, events, and inheritance. When you finish these lessons, you should have the knowledge you need to go on to a good text on JavaBeans technology and continue your studies.



0201707209P04062001

Table of Contents

Preface xiii
Compiling and Running a Simple Program
1(8)
Covered in This Lesson
1(1)
A Word About the Java Platform
2(1)
Setting Up Your Computer
3(1)
Writing a Program
3(1)
Compiling the Program
3(1)
Interpreting and Running the Program
4(1)
Code Comments
5(1)
Double Slashes
5(1)
C-Style Comments
5(1)
Doc Comments
5(1)
API Documentation
6(1)
Setting the CLASSPATH Environment Variable on a Windows Platform
6(1)
Exercises
6(1)
More Information
7(2)
Building Applications
9(8)
Covered in This Lesson
9(1)
Application Structure and Elements
9(3)
Fields and Methods
12(2)
Constructors
14(2)
To Summarize
16(1)
Exercises
16(1)
More Information
16(1)
Building Applets
17(8)
Covered in This Lesson
17(1)
Application to Applet
17(2)
Run the Applet
19(1)
Applet Structure and Elements
19(4)
Extending a Class
20(1)
Behavior
21(1)
Appearance
22(1)
Packages
23(1)
Exercises
24(1)
More Information
24(1)
Building a User Interface
25(12)
Covered in This Lesson
25(1)
Project Swing APIs
26(1)
Import Statements
26(2)
Class Declaration
28(1)
Instance Variables
29(1)
Constructor
29(2)
Action Listening
31(1)
Event Handling
32(1)
main Method
32(1)
Exercises: Applets Revisited
33(2)
Summary
35(1)
More Information
35(2)
Building Servlets
37(10)
Covered in This Lesson
37(1)
About the Example
38(1)
HTML Form
38(2)
Servlet Code
40(3)
Class and Method Declarations
41(1)
Method Implementation
42(1)
JavaServer Pages Technology
43(2)
HTML Form
43(1)
JSP Page
44(1)
Exercises
45(1)
More Information
46(1)
File Access and Permissions
47(22)
Covered in This Lesson
47(1)
File Access by Applications
48(1)
Constructor and Instance Variable Changes
49(1)
Method Changes
49(3)
System Properties
52(1)
File.separatorChar
52(1)
Exception Handling
52(3)
File Access by Applets
55(2)
Granting Applets Permission
57(1)
Creating a Policy File
57(1)
Running an Applet with a Policy File
57(1)
Restricting Applications
58(1)
File Access by Servlets
59(1)
Exercises
59(1)
More Information
60(1)
Code for This Lesson
61(8)
FileIO Program
61(2)
FileIOAppl Program
63(2)
FileIOServlet Program
65(1)
AppendIO Program
66(3)
Database Access and Permissions
69(20)
Covered in This Lesson
69(1)
Database Setup
70(1)
Create Database Table
70(1)
Database Access by Applications
70(4)
Establishing a Database Connection
71(1)
Final and Private Variables
72(1)
Writing and Reading Data
73(1)
Database Access by Applets
74(4)
JDBC Driver
75(1)
JDBC-ODBC Bridge with ODBC Driver
76(2)
Database Access by Servlets
78(1)
Exercises
79(1)
More Information
79(1)
Code for This Lesson
79(10)
Dba Program
79(3)
DbaAppl Program
82(2)
DbaOdbAppl Program
84(2)
DbaServlet Program
86(3)
Remote Method Invocation
89(18)
Covered in This Lesson
90(1)
About the Example
90(8)
Program Behavior
90(1)
File Summary
90(2)
Compile the Example
92(1)
Start the RMI Registry
93(2)
Start the Server
95(1)
Run the RMIClient1 Program
96(1)
Run the RMIClient2 Program
97(1)
RemoteServer Class
98(1)
Send Interface
99(1)
RMIClient1 Class
99(1)
actionPerformed Method
99(1)
mainMethod
100(1)
RMIClient2 Class
100(2)
actionPerformed Method
101(1)
main Method
101(1)
Exercises
102(1)
More Information
102(1)
Code for This Lesson
102(5)
RMIClient1 Program
102(2)
RMIClient2 Program
104(1)
RemoteServer Program
105(1)
Send Interface
106(1)
Socket Communications
107(16)
Covered in This Lesson
107(1)
What Are Sockets and Threads?
108(1)
About the Examples
108(2)
Client-Side Behavior
109(1)
Server-Side Behavior
109(1)
Compile and Run
110(1)
Example 1: Single-Threaded Server Example
110(3)
Server-Side Program
110(1)
Client-Side Program
111(2)
Example 2: Multihreaded Server Example
113(3)
Exercises
116(1)
More Information
116(1)
Code for This Lesson
116(7)
SocketClient Program
116(2)
SocketServer Program
118(2)
SocketThrdServer Program
120(3)
User Interfaces Revisited
123(30)
Covered in This Lesson
123(1)
About the Example
124(4)
Fruit Order Client (RMIClient1)
124(1)
Server Program
125(1)
View Order Client (RMIClient2)
125(1)
Compile and Run the Example
126(2)
Fruit Order (RMIClient1) Code
128(7)
Instance Variables
128(1)
Constructor
129(2)
Event Handling
131(2)
Cursor Focus
133(1)
Converting Strings to Numbers and Back
134(1)
Server Program Code
135(1)
Send Interface
135(1)
RemoteServer Class
135(1)
View Order Client (RMIClient2) Code
136(2)
Exercises
138(1)
Calculations and Pressing Return
138(1)
Nonnumber Errors
138(1)
Extra Credit
138(1)
More Information
139(1)
Code for This Lesson
139(14)
RMIClient1 Program
139(4)
RMIClient2 Program
143(4)
RMIClient1 Improved Program
147(6)
Developing the Example
153(16)
Covered in This Lesson
153(1)
Tracking Orders
153(4)
sendOrder Method
154(1)
getOrder Method
154(1)
Other Changes to Server Code
155(2)
Maintaining and Displaying a Customer List
157(4)
About Collections
157(1)
Creating a Set
158(1)
Accessing Data in a Set
159(1)
Displaying Data in a Dialog Box
160(1)
Exercises
161(1)
More Information
162(1)
Code for This Lesson
162(7)
RemoteServer Program
162(2)
RMIClient2
164(5)
Internationalization
169(24)
Covered in This Lesson
169(1)
Identify Culturally Dependent Data
169(2)
Create Keyword and Value Pair Files
171(4)
German Translations
173(1)
French Translations
174(1)
Internationalize Application Text
175(3)
Instance Variables
175(1)
main Method
175(2)
Constructor
177(1)
actionPerformed Method
178(1)
Internationalize Numbers
178(1)
Compile and Run the Application
179(2)
Compile
179(1)
Start the RMI Registry
180(1)
Start the Server
180(1)
Start the RMIClient1 Program in German
180(1)
Start the RMIClient2 Program in French
181(1)
Exercises
181(1)
More Information
182(1)
Code for This Lesson
183(10)
RMIClient1
183(4)
RMIClient2
187(6)
Packages and JAR File Format
193(12)
Covered in This Lesson
193(1)
Setting up Class Packages
193(3)
Create the Directories
194(1)
Declare the Packages
195(1)
Make Classes and Fields Accessible
195(1)
Change Client Code to Find the Properties Files
196(1)
Compile and Run the Example
196(3)
Compile
197(1)
Start the RMI Registry
197(1)
Start the Server
198(1)
Start the RMIGermanApp Program
198(1)
Start the RMIClient2 Program in French
198(1)
Using JAR Files to Deploy
199(3)
Server Set of Files
199(1)
Fruit Order Set of Files (RMIClient1)
200(2)
View Order Set of Files
202(1)
Exercises
202(1)
More Information
203(2)
Object-Oriented Programming
205(12)
Covered in This Lesson
205(1)
Object-Oriented Programming Defined
206(3)
Classes
206(1)
Objects
207(1)
Well-Defined Boundaries and Cooperation
207(2)
Inheritance and Polymorphism
209(2)
Data Access Levels
211(2)
Classes
212(1)
Fields and Methods
212(1)
Global Variables and Methods
213(1)
Your Own Classes
213(2)
Well-Defined Boundaries and Cooperation
214(1)
Inheritance
214(1)
Access Levels
215(1)
Exercises
215(1)
More Information
216(1)
Appendix A Cryptography 217(22)
Covered in This Lesson
217(1)
About the Example
218(2)
Compiling and Running the Example
220(1)
Source Code
220(17)
Sealing the Symmetric Key
221(8)
Encrypting the Symmetric Key with the RSA Algorithm
229(8)
Exercises
237(1)
More Information
237(2)
Appendix B Code Listings 239(50)
Covered in This Lesson
239(1)
Application Code
239(26)
RMIClient1
240(5)
RMIClient2
245(4)
DataOrder
249(1)
Send
249(1)
RemoteServer
250(1)
RMIFrenchApp
251(5)
RMIGermanApp
256(4)
RMIEnglishApp
260(5)
Cryptography Example
265(24)
Sealing the Symmetric Key: RMIClient1 Program
265(6)
Sealing the Symmetric Key: RMIClient2 Program
271(5)
Encrypting the Symmetric Key with the RSA Algorithm: RMIClient1 Program
276(7)
Encrypting the Symmetric Key with the RSA Algorithm: RMIClient2 Program
283(6)
Further Reading 289(2)
Index 291

Introduction

If you are new to programming in the Java™ language and have some experience with other languages, this tutorial could be for you. It walks you through how to use the Java 2 Platform software to develop a basic network application that uses common Java 2 platform features. This tutorial is not comprehensive, but instead it takes you on a straight and uncomplicated path through the more common features available in the Java platform. This tutorial is a learning tool and should be viewed as a stepping-stone for persons who find the currently available materials a little too overwhelming to start with.

To reduce your learning curve, this tutorial begins with a simple program in Lesson 1, develops the program by adding new features in every lesson, and leaves you with a general electronic commerce application and a basic understanding of object-oriented programming concepts in Lesson 15. Unlike other, more reference-style texts that give you a lot of definitions and concepts at the beginning, this tutorial takes a practical approach. New features and concepts are described when they are added to the example application, and the end of each lesson points to texts where you can get more information.

Please note the final application is for instructional purposes only and would need more work to make it production worthy. By the time you finish this tutorial, you should have enough knowledge to go on comfortably to other Java programming language learning materials currently on the market and continue your studies.

If you have no programming experience at all, you might still find this tutorial helpful; but you also might want to take an introductoryprogramming course before you proceed.

Lessons 1 through 8 explain how applications, applets, and servlets/JavaServer Pages™ are similar and different, how to build a basic user interface that handles simple user input, how to read data from and write data to files and databases, and how to send and receive data over the network.

Lessons 9 through 15 are somewhat more complex and build on the material presented in the first eight lessons. These lessons walk you through socket communications, building a user interface using more components, grouping multiple data elements as one unit (collections), saving data between program invocations (serialization), and internationalizing a program. Lesson 15 concludes the series with basic object-oriented programming concepts.

This tutorial covers object-oriented concepts at the end, after you have had practical experience with the language so you can relate the object-oriented concepts to your experiences. This should make learning the concepts a little easier. Remember, this tutorial is a learning tool, and the intention is that you gain enough experience and information here to go on comfortably to other more comprehensive and in-depth texts to continue your studies.

Appendix A provides a version of the enterprise example that uses encryption and decryption technology to pass a credit card number over the network. This material is in an appendix because the encryption and decryption software is currently available only in the United States and Canada.

Appendix B presents the complete and final code for this tutorial.

Note: JavaBeans™ technology, which lets you create portable program components that follow simple naming and design conventions, is not covered here. While creating a simple JavaBean component is easy, understanding JavaBeans features requires knowledge of such things as properties, serialization, events, and inheritance. When you finish these lessons, you should have the knowledge you need to go on to a good text on JavaBeans technology and continue your studies.



Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews