CCL Home Page
Up Directory CCL t018.html

Jan K. Labanowski: "Tomcat, servlets, JSPs and other friends"


Java classes are usually organized in packages which group together related classes. The classes in the package are placed under the some directorory. Related packages are usually organized hierarchically, i.e., as directory tree. E.g., class javax.servlet.http.Cookie is a part of javax.servlet.http package, and its bytecode resides in the file: /some/dir/javax/servlet/http/Cookie.class. If the Cookie class is needed by your Java application/servlet/applet, you need to either refer to it by its full name: javax.servlet.http.Cookie or place an import statement at the top of your source file:

import javax.servlet.http.Cookie;
Cookie saveId = new Cookie("User", userId);
But how the java or javac knows where the /some/dir/javax/servlet/http/Cookie.class is located? From the CLASSPATH which either lists top directories for packages (in example above: /some/dir) or jar files.

Modified: Wed Feb 13 03:43:20 2002 GMT
Page accessed 2310 times since Tue Feb 4 16:02:32 2003 GMT