If you are interested in learning the Java™ programming language but hesitate to dive into overly dense, theoretical resources, Essentials of the Java™ Programming Language is the perfect starting point. This accessible, hands-on tutorial employs a "learn-by-doing" approach to introduce you to the basics. It starts with a simple program, then develops it bit by bit, adding new features and explaining important concepts with each subsequent lesson. This simple program grows into a general electronic commerce application that illustrates many of the Java 2 platform's most important elements.
You will learn such Java programming language essentials as:
Essentials of the Java™ Programming Language ends with an explanation of object-oriented programming concepts, made far more understandable and relevant as a result of the hands-on experience acquired throughout the book. After working through this book, you will have the foundation necessary to comfortably progress to more advanced learning materials for the Java programming language and utilize the subtleties and more sophisticated capabilities of the language.
Preface.
Acknowledgments.
LESSON 1.
Compiling and Running a Simple Program.
Covered in This Lesson.
A Word About the Java Platform.
Setting Up Your Computer.
Writing a Program.
Compiling the Program.
Interpreting and Running the Program.
Code Comments.
Double Slashes.
C-Style Comments.
Doc Comments.
API Documentation.
Setting the CLASSPATH Environment Variable on a Windows Platform.
Exercises.
More Information.
Building Applications.
Covered in This Lesson.
Application Structure and Elements.
Fields and Methods.
Constructors.
To Summarize.
Exercises.
More Information.
Building Applets.
Covered in This Lesson.
Application to Applet.
Run the Applet.
Applet Structure and Elements.
Extending a Class.
Behavior.
Appearance.
Packages.
Exercises.
More Information.
Building a User Interface.
Covered in This Lesson.
Project Swing APIs.
Import Statements.
Class Declaration.
Instance Variables.
Constructor.
Action Listening.
Event Handling.
Main Method.
Exercises: Applets Revisited.
Summary.
More Information.
Building Servlets.
Covered in This Lesson.
About the Example.
HTML Form.
Servlet Code.
Class and Method Declarations.
Method Implementation.
JavaServer Pages.
HTML Form.
JavaServer Page.
Exercises.
More Information.
File Access and Permissions.
Covered in This Lesson.
File Access by Applications.
Constructor and Instance Variable Changes.
Method Changes.
System Properties.
File.separatorChar.
Exception Handling.
File Access by Applets.
Granting Applets Permission.
Creating a Policy File.
Running an Applet with a Policy File.
Restricting Applications.
File Access by Servlets.
Exercises.
More Information.
Code for This Lesson.
FileIO Program.
FileIOAppl Program.
FileIOServlet Program.
AppendIO Program.
Database Access and Permissions.
Covered in This Lesson.
Database Setup.
Create Database Table.
Database Access by Applications.
Establishing a Database Connection.
Final and Private Variables.
Writing and Reading Data.
Database Access by Applets.
JDBC Driver.
JDBC-ODBC Bridge with ODBC Driver.
Database Access by Servlets.
Exercises.
More Information.
Code for This Lesson.
Dba Program.
DbaAppl Program.
DbaOdbAppl Program.
DbaServlet Program.
Remote Method Invocation.
Covered in This Lesson.
About the Example.
Program Behavior.
File Summary.
Compile the Example.
Start the RMI Registry.
Start the Server.
Run the RMIClient1 Program.
Run the RMIClient2 Program.
RemoteServer Class.
Send Interface.
RMIClient1 Class.
actionPerformed Method.
main Method.
RMIClient2 Class.
actionPerformed Method.
main Method.
Exercises.
More Information.
Code for This Lesson.
RMIClient1 Program.
RMIClient2 Program.
RemoteServer Program.
Send Interface.
Socket Communications.
Covered in This Lesson.
What are Sockets and Threads?
About the Examples.
Example 1: Client-Side Behavior.
Example 1: Server-Side Behavior.
Example 1: Compile and Run.
Example 1: Server-Side Program.
listenSocket Method.
actionPerformed Method.
Example 1: Client-Side Program.
listenSocket Method.
actionPerformed Method.
Example 2: Multithreaded Server Example.
Exercises.
More Information.
Code for This Lesson.
SocketClient Program.
SocketServer Program.
SocketThrdServer Program.
User Interfaces Revisited.
Covered in This Lesson.
About the Example.
Fruit Order Client (RMIClient1).
Server Program.
View Order Client (RMIClient2).
Compile and Run the Example.
Fruit Order (RMIClient1) Code.
Instance Variables.
Constructor.
Event Handling.
Cursor Focus.
Converting Strings to Numbers and Back.
Server Program Code.
Send Interface.
RemoteServer Class.
View Order Client (RMIClient2) Code.
Exercises.
Calculations and Pressing Return.
Non-Number Errors.
Extra Credit.
More Information.
Code for This Lesson.
RMIClient1 Program.
RMIClient2 Program.
RMIClient1 Improved Program.
Developing the Example.
Covered in This Lesson.
Tracking Orders.
sendOrder Method.
getOrder Method.
Other Changes to Server Code.
Maintaining and Displaying a Customer List.
About Collections.
Creating a Set.
Accessing Data in a Set.
Displaying Data in a Dialog Box.
Exercises.
More Information.
Code for This Lesson.
RemoteServer Program.
RMIClient2.
Internationalization.
Covered in This Lesson.
Identify Culturally Dependent Data.
Create Keyword and Value Pair Files.
German Translations.
French Translations.
Internationalize Application Text.
Instance Variables.
main Method.
Constructor.
actionPerformed Method.
Internationalize Numbers.
Compile and Run the Application.
Compile.
Start the RMI Registry.
Start the Server.
Start the RMIClient1 Program in German.
Start the RMIClient2 Program in French.
Exercises.
More Information.
Code for This Lesson.
RMIClient1.
RMIClient2.
Packages and JAR File Format.
Covered in This Lesson.
Setting up Class Packages.
Create the Directories.
Declare the Packages.
Make Classes and Fields Accessible.
Change Client Code to Find the Properties Files.
Compile and Run the Example.
Compile.
Start the RMI Registry.
Start the Server.
Start the RMIGermanApp Program.
Start the RMIClient2 Program in French.
Using JAR Files to Deploy.
Server Set of Files.
Fruit Order Set of Files (RMIClient1).
View Order Set of Files.
Exercises.
More Information.
Object-Oriented Programming.
Covered in This Lesson.
Object-Oriented Programming.
Classes.
Objects.
Well-Defined Boundaries and Cooperation.
Inheritance and Polymorphism.
Data Access Levels.
Classes.
Fields and Methods.
Global Variables and Methods.
Your Own Classes.
Well-Defined Boundaries and Cooperation.
Inheritance.
Access Levels.
Exercises.
More Information.
Cryptography.
Covered in This Lesson.
About the Example.
Compiling and Running the Example.
Source Code.
Sealing the Symmetric Key.
Encrypting the Symmetric Key with the RSA Algorithm.
Exercises.
More Information.
APPENDIX B.
Code Listings.
Covered in This Lesson.
Application Code.
Application Code.
RMIClient1.
Application Code.
RMIClient2.
Application Code.
DataOrder.
Application Code:
Send.
Application Code.
RemoteServer.
Application Code.
RMIFrenchApp.
Application Code.
RMIGermanApp.
Application Code.
RMIEnglishApp.
Cryptography Example.
Sealing the Symmetric Key.
RMIClient1 Program.
Sealing the Symmetric Key.
RMIClient2 Program.
Encrypting the Symmetric Key with the RSA Algorithm.
RMIClient1 Program.
Encrypting the Symmetric Key with the RSA Algorithm.
RMIClient2 Program.
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 introductory 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.
