Java Reference
In-Depth Information
the package in that directory, and tell the Java compiler once and for all how to
locate the class files.
You need to add the directories that might contain packages to the class path. In the
preceding example, you add the /home/walters/lib directory to that class
path . The details for doing this depend on your compilation environment; consult
the documentation for your compiler, or your instructor. If you use the Sun Java
SDK, you need to set the class path. The exact command depends on the operating
system. In UNIX, the command might be
366
367
export CLASSPATH=/home/walters/lib:.
This setting places both the /home/walters/lib directory and the current
directory onto the class path. (The period denotes the current directory.)
Figure 5
Base Directories and Subdirectories for Packages
A typical example for Windows would be
set CLASSPATH=c:\home\walters\lib;.
Note that the class path contains the base directories that may contain package
directories. It is a common error to place the complete package address in the class
path. If the class path mistakenly contains
/home/walters/lib/com/horstmann/bigjava , then the compiler will
Search WWH ::




Custom Search