Hi everyone i am newbie to this community.I am reading head first servlets .I got an error showing package com.example.model.*; doesnot exist .........
I set my environmental variable classpath as C:\Program Files\Java\jdk1.6.0\lib\tools.jar;C:\Program Files\Java\jdk1.6.0\lib\dt.jar;.;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;%CLASSPATH%;
I can compile BeerExpert.java but i cannot compile BeerSelect.java file
my directory structure for BeerSelect.java is C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\chanti3\WEB-INF\classes\com\example\web\BeerSelect.java
my directory structure for BeerExpert.java is C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\chanti3\WEB-INF\classes\com\example\model\BeerExpert.java
I got the error in the line import com.example.model.*;
......how can i set classpath entry ? how can i solve this problem?
That is, add a CLASSPATH entry just as you have done for the others above pointing to the top level directory which contains your compiled classes (with the correct package heirarchy). This case the directory contains com/example/model.
Joined: Aug 19, 2009
Thanks for your help Vijitha Kumara but still the same errors continues package com.example.model doesnot exist ................ i jus changed directories like what you have said...................
and my changed directory structure is
E:\projects\p3\src\com\example\model\BeerExpert.java------------this one is compiling and creating .class file at E:\projects\p3\classes\com\example\model\BeerExpert.class
the source code for BeerSelect.java is
import com.example.model.*; ----------error in importing this
srinivas venkat wrote:i am compiling using the following command
E:\projects\p3>javac -classpath "C:\Program Files\Apache Software Foundation\Tom
cat 5.0\common\lib\servlet-api.jar";"E:\projects\p3\classes\com\example\model";classes:. -d classes src\com\example\web\BeerSelect.java
No. I mean you have to add the directory which contains the "com\example\model" to the CLASSPATH, that is "E:\projects\p3\classes\". Try with this & "C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar" as the -classpath entries (remove all the others) and It should compile.
Or even if you include "classes" in the classpath (with the servlet.jar ofcourse) it should work as it seems you are having the classes directory in the current directory (i.e: the one you are compiling from)
Joined: Aug 19, 2009
That solved my problem........ i am a beginner started learning servlets and jsps so dont mind if i ask any silly doubts.......Thanks a lot for your help vijitha Kumara ....