Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
1.5 Installation and Setup
15
classes when compiling. If the variable is unspecified,
javac
looks in the cur
rent directory and the standard system libraries. If you set
CLASSPATH
your
self, be sure to include
.
, signifying the current directory.
Following is a brief summary of how to set the environment variable on a
couple of different platforms. Assume
dir
is the directory in which the serv
let and JSP classes are found.
Unix (C Shell)
setenv CLASSPATH .:dir/servlet.jar:dir/jspengine.jar
Add
:$CLASSPATH
to the end of the
setenv
line if your
CLASSPATH
is
already set and you want to add more to it, not replace it. Note that on Unix
systems you use forward slashes to separate directories within an entry and
colons to separate entries, whereas you use backward slashes and semicolons
on Windows. To make this setting permanent, you would typically put this
statement in your
.cshrc
file.
Windows
set CLASSPATH=.;dir\servlet.jar;dir\jspengine.jar
Add
;%CLASSPATH%
to the end of the above line if your
CLASSPATH
is
already set and you want to add more to it, not replace it. Note that on Win
dows you use backward slashes to separate directories within an entry and
semicolons to separate entries, while you use forward slashes and colons on
Unix. To make this setting permanent on Windows 95/98, you'd typically put
this statement in your
autoexec.bat
file. On Windows NT or 2000, you
would go to the Start menu, select Settings, select Control Panel, select Sys
tem, select Environment, then enter the variable and value.
Package the Classes
As you'll see in the next chapter, you probably want to put your servlets into
packages to avoid name conflicts with servlets other people write for the
same Web or application server. In that case, you may find it convenient to
add the top level directory of your package hierarchy to the
CLASSPATH
as
well. See Section 2.4 (Packaging Servlets) for details.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved