In Chapter 1 of the text we discussed the life cycle of a computer program:
Steps 1, 2 and 6 you can do in your head, but steps 3, 4 and 5 need to be done on a computer. For step 3 you need a word processor (text editor) of some kind. For step 4 you need the Java compiler. For step 5 you need the Java Virtual Machine. To work on the examples in Java Outside In you will need access to the Java code discussed in the text.
There are three ways you might arrange to have all these software tools available on your computer. Some combination will work for you.
The Java compiler and the Java Virtual Machine are available free for Windows, Solaris or Linux at http://java.sun.com/. You should download the latest production version of the JavaTM2 Platform, Standard Edition (J2SETM) from http://java.sun.com/j2se/downloads.html.
If you are using a Macintosh computer you will find these tools already installed as part of Mac OS X. For earlier versions of the Macintosh operating system, search the web for information.
Once you have installed Java you may write your programs using any word processor you like. On a Windows PC Microsoft Word, or just plain Notepad will do. On Unix or Linux you will use either vi or emacs as an editor. Compile and run your program from any command prompt.
You can get a free emacs editor for Windows, Unix/Linux or Mac OS X at http://www.xemacs.org/Download/. Warning: emacs is a powerful programming editor but not easy for beginners.
In the real software world editors and compilers are usually combined in an IDE - an integrated development environment. The editor will display language keywords and comments in different colors. It may prettyprint for you. You can compile and run programs without leaving the environment, which will help you locate errors in your code. Here are several you might want to consider:
A Google search for "Free Java IDE" will turn up more candidates. Some of these environments may come with Java installed, in which case you won't need to get a copy separately.
The Java compiler and the Java Virtual Machine know how to find all the classes (like String) that come with the Java library. But there are times when your program needs access to other classes that you have not written. In particular, many of the programs in Java Outside In use the Terminal class. You can make such classes available to your program in several ways.
Whatever.javacreates a Terminal object. In a Windows system you might put
C:\joi\classes. Then you could invoke Java this way
> javac -classpath .;C:\joi\classes Whatever.java > java -classpath .;C:\joi\classes Whateverto compile and run Whatever.java.
On Windows you might
CLASSPATHenvironment variable on your computer to
.;C:\joi\classes. This tells Java to look for classes (such as Terminal) both in the current working folder (
.) and in
C:\joi\classes. (You may make the list of folders in the classpath as long as you like.)
In a Unix (or Linux) system, replace the file separator
and the path separator
. and set the
CLASSPATH environment variable in your login script.
If you are using an IDE, you may be able to set the class path in the IDE itself
The source code is on this CD in file \terminal\Terminal.java. The class file is in file \terminal\Terminal.class for you to copy.
There are two ways you arrange to use a Terminal.
But this can become cumbersome after a while.
Off you go. Have fun!