Java: An Introduction to Computer Science and Programming, Second Edition

Walter Savitch

Frequently Asked Questions

  1. I cannot get the SavitchIn class to work. The compiler keeps saying something like Undefined variable or class name: SavitchIn
    Answer:
    You must treat the file SavitchIn.java just like code you yourself write.
    If you are using JBuilder , then you must include both your program and SavitchIn.java in a project. See appendix 12 on JBuilder for details.
    If you are using CodeWarrior, you must include both your program and the file SavitchIn.java in a project.
    If you are using TextPad or if you compile by giving the command javac to compile your program, then place both your program and SavitchIn.java in the same directory (same folder) and compile both your program and SavitchIn,java. See the section in Chapter 1 entitled
    Compiling a Java Program or Class" for more details.
  2. When I try to install the version of JBuilder that comes on the CD, it asks me for some numbers or keys or something. What are these?
    Answer:
    All the numbers you need and full instructions for installing JBuilder are given in Appendix 12 of the text.
  3. What version of Java do I need?
    Answer:
    You need "Java 2," but the names can be confusing. If you are downloading a compiler from the Sun website , you need version 1.2 or higher of the SDK (also called the JDK). For example, version 1.2.1 or version 1.3 is fine.
    If you are using JBuilder on a PC , you have all that you need on the CD that comes with the book.
  4. I am using JBuilder (or CodeWarrior). Do I need to also download the Java compiler from the Sun website?
    Answer:
    No. JBuilder and CodeWarrior are complete environments that include their own compiler.
  5. I am on a Mac. What version of Java should I use?
    Answer:
    There are not too many good options fro the Mac, but you do have one or two. You can use CodeWarrior for the Mac. When it comes out (due any day now), you can use JBuilder for the Mac.
  6. Can I use Microsoft's J++ with this book?
    Answer:
    Microsoft's J++ does not include the Swing libraries. To use J++ you should add the Swing libraries, which I'm told is nontrivial to do. I suggest that you use something other than J++. See, the preface of the book for suggestions (most of them available free of charge).
  7. Do I need to set my PATH variable after I install the Sun Java compiler?
    Answer:
    You do not technically "need to," but you want to set it, or else it can be difficult to give the command to compile a program or class.
  8. Do I need to set the CLASSPATH variable?
    Answer:
    You do not need to set the CLASSPATH variable unless you are creating and using your own packages. With no CLASSPATH variable you can use all the standard Java packages, but all classes used by your program (such as SavitchIn.java) must be in the same directory (same folder) as your program.
    If you plan to define your own package , I advise you to set the CLASSPATH variable. (I know that Sun does not suggest this, but the alternative they suggest seems like more of a pain to me then setting the CLASSPATH variable.)