Essentials of the Java Programming part II 2000.pdf

(867 KB) Pobierz
Essentials of the Java(TM) Programming Language, Part 2
Essentials of the Java(TM) Programming Language, Part 2
A-Z Index
Java
Home
Page
Online Training
Java Developer Connection(SM)
Downloads, APIs,
Documentation
Java Developer
Connection
Training
Online Support
Essentials of the Java TM Programming
Language: A Hands-On Guide, Part 2
by Monica Pawlan
[ CONTENTS ] [ NEXT>> ]
News & Events from
Everywhere
Products from
Everywhere
How Java Technology
is Used Worldwide
This series of lessons builds on the material presented in Java TM
applications, applets, and servlets; simple file and database access
operations; and remote method invocation (RMI).
Print Button
The lessons and code examples for Part 2 are somewhat more
complex. They walk you through network communications, building
a user interface using more components, data encryption and
decryption (pseudo code only), grouping multiple data elements
into one object (collections), and internationalizing a program. Part
2 concludes with some object-oriented programming concepts.
Contents
What are Sockets and Threads?
l
About the Examples
l
Example 1: Server-Side Program
l
Example 1: Client-Side Program
l
Example 2: Multithreaded Server Example
l
More Information
About the Example
l
Fruit Order Client Code
Global Variables
m
m
Constructor
m
Event Handling
m
Cursor Focus
m
Converting Strings to Numbers and Back
l
Server Program Code
l
View Order Client Code
l
Program Improvements
file:///T|/General/Documentation/Java/Basic Java 2/HTML/index.html (1 of 3) [24.07.2000 12:33:21]
l
l
22941913.003.png
Essentials of the Java(TM) Programming Language, Part 2
l
More Information
Lesson 3: Cryptography
About the Example
l
Running the Example
l
Pseudo Code
l
More Information
Lesson 4: Serialization
About the Example
l
Wrapping the Data
l
Sending Data
l
Server Program
l
Receiving Data
l
More Information
Lesson 5: Collections
About Collections
l
Creating a Set
l
Printing
l
More Information
Identify Culturally Dependent Data
l
Create Keyword and Value Pair Files
l
Internationalize Application Text
l
Localize Numbers
l
Compile and Run the Application
l
Program Improvements
l
More Information
Setting up Class Packages
Create the Directories
m
m
Declare the Packages
m
Make Classes and Fields Accessible
m
Change Client Code to Find the Properties File
m
Compile and Run the Example
l
Using JAR Files to Deploy
Server Set of Files
m
m
Fruit Order Client Set of Files
m
View Order Client Set of Files
m
More Information
file:///T|/General/Documentation/Java/Basic Java 2/HTML/index.html (2 of 3) [24.07.2000 12:33:21]
l
l
l
l
l
Essentials of the Java(TM) Programming Language, Part 2
Object-Oriented Programming Defined
l
Classes
l
Objects
l
Well-Defined Boundaries and Cooperation
l
Inheritance
l
Polymorphism
l
Data Access Levels
l
Your Own Classes
l
Program Improvements
l
More Information
Reader Feedback
Tell us what you think of this training book and earn two
DukeDollars.
[Duke]
Very worth reading Worth reading Not worth
reading
If you have other comments or ideas for future training
books, please type them here:
[ TOP ]
Print Button
[ This page was updated: 6-Apr-2000 ]
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's
Sun
Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use . Privacy Policy .
file:///T|/General/Documentation/Java/Basic Java 2/HTML/index.html (3 of 3) [24.07.2000 12:33:21]
l
22941913.004.png 22941913.005.png
Java (TM) Language Basics, Part 2, Lesson 1: Socket Communications
A-Z Index
Java
Home
Page
Online Training
Java Developer Connection(SM)
Downloads, APIs,
Documentation
Java Developer
Connection
Training
Online Support
Java TM Programming Language Basics,
Part 2
Lesson 1: Socket Communications
[ <<BACK ] [ CONTENTS ] [ NEXT>> ]
News & Events from
Everywhere
Products from
Everywhere
How Java Technology
is Used Worldwide
simple network communications example using the Remote Method
Invocation (RMI) application programming interface (API). The RMI
example allows multiple client programs to communicate with the
same server program without any explicit code to do this because
the RMI API is built on sockets and threads.
Print Button
This lesson presents a simple sockets-based program to introduce
the concepts of sockets and multi-threaded programming. A
multi-threaded program performs multiple tasks at one time such
as fielding simultaneous requests from many client programs.
What are Sockets and Threads?
l
About the Examples
l
Example 1: Server-Side Program
l
Example 1: Client-Side Program
l
Example 2: Multithreaded Server Example
l
More Information
What are Sockets and Threads?
A socket is a software endpoint that establishes bidirectional
communication between a server program and one or more client
programs. The socket associates the server program with a specific
hardware port on the machine where it runs so any client program
anywhere in the network with a socket associated with that same
port can communicate with the server program.
A server program typically provides
resources to a network of client
programs. Client programs send
requests to the server program, and
the server program responds to the
request.
One way to handle requests from
more than one client is to make the
server program multi-threaded. A
multi-threaded server creates a thread for each communication it
accepts from a client. A thread is a sequence of instructions that
file:///T|/General/Documentation/Java/Basic Java 2/HTML/socket.html (1 of 9) [24.07.2000 12:33:27]
l
22941913.006.png
Java (TM) Language Basics, Part 2, Lesson 1: Socket Communications
run independently of the program and of any other threads.
Using threads, a multi-threaded server program can accept a
connection from a client, start a thread for that communication,
and continue listening for requests from other clients.
About the Examples
The examples for this lesson consist of two versions of the client
and server program pair adapted from the FileIO.java application
Example 1 sets up a client and server communication between one
server program and one client program. The server program is not
multi-threaded and cannot handle requests from more than one
client.
Example 2 converts the server program to a multi-threaded version
so it can handle requests from more than one client.
Example 1: Client-Side Behavior
The client program presents a simple user interface and prompts
for text input. When you click the Click Me button, the text is sent to
the server program. The client program expects an echo from the
server and prints the echo it receives on its standard output.
Example 1: Server-Side Behavior
The server program presents a simple user interface, and when you
click the Click Me button, the text received from the client is
displayed. The server echoes the text it receives whether or not
you click the Click Me button.
Example 1: Compile and Run
To run the example programs, start the server program first. If you
do not, the client program cannot establish the socket connection.
file:///T|/General/Documentation/Java/Basic Java 2/HTML/socket.html (2 of 9) [24.07.2000 12:33:27]
22941913.001.png 22941913.002.png
Zgłoś jeśli naruszono regulamin