| Some of the examples in the Second Edition of the textbook use a class
called Keyboard to facilitate keyboard input and simplify early programs.
The Keyboard class was designed by the authors of the textbook. It is not part of
the Java standard class library. The Keyboard class is designed as a classic
abstraction: hiding potentially confusing details until they are needed. Chapter 8 of the
textbook discusses the internal details of the Keyboard class, exploring Java issues that
are unnecessarily intrusive until early groundwork has been addressed.
You may view and / or download the source code to see how the class works:
Download / View Keyboard.java
You may also download a one-page Word document that describes the methods of the
Keyboard class in a manner similar to Appendix M.
Download the Description of the
Keyboard class
The Keyboard class is declared to be part of the cs1 package and is in
fact the only member of the cs1 package initially. Faculty and students may choose to add
classes to the cs1 package as desired.
Installing the Keyboard class
Students note: you should be installing the Keyboard class only on your
own personal computer. Your instructor or school system administrator will have already
installed the Keyboard class on the school's computers.
The following instructions apply if you are using the Java Software Development Kit
(SDK). If you are using another development environment, consult your instructor or the
development environment's documentation to find out how to use the Keyboard class in your
programming projects.
To make the Keyboard class available to the Java SDK on your computer, first download
the following ZIP file. This zip file contains a JAR (Java Archive) file of the cs1
package, including the bytecode version of the Keyboard class. The download file is
presented in the ZIP format to avoid compatibility problems of downloading JAR files using
Netscape.
Download cs1jar.zip
Extract the cs1.jar file and store it in the C:\jdk1.3\jre\lib\ext
directory (assuming the Java SDK was installed in C:\jdk1.3). This
directory is one of the places where the Java compiler and interpreter look for classes
that you refer to in your Java programs.
You will likely have to store the JAR file in a second location as well. Store a copy
of the JAR file in a similar directory where the Java Runtime Environment (JRE) was
stored. If you used the defaults when installing the Java SDK, the second location for the
JAR file is C:\Program Files\JavaSoft\JRE\1.3\lib\ext. At one time this
second directory was only used in Windows NT and Windows 2000 systems, but now it is
needed for all Windows based operating systems.
Once you have the JAR file stored in the correct locations, the compiler and
interpreter should be able to find and use the Keyboard class when imported. |