• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem compiling servlet class  RSS feed

 
thirun pavan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to compile servlet code example provided in HF Servlet and JSP book, yet every time I get error:

package com.example.model does not exist
import com.example.model.*;

The code used in the class is as follows:




This class is located at:
/var/lib/tomcat6/webapps/Beer-v1/WEB-INF/classes/com/example/web/

and I was compiling from the folder:
/var/lib/tomcat6/webapps/Beer-v1/WEB-INF/classes/com/example/web/

using the command:
javac -classpath /usr/share/tomcat6/lib/servlet-api.jar:classes:. /var/lib/tomcat6/webapps/Beer-V1/WEB-INF/classes/com/example/web/BeerSelect.java

Taking in consideration that the BeerExpert.class file is at:
/var/lib/tomcat6/webapps/Beer-v1/WEB-INF/classes/com/example/model/

Can someone please tell me what I might be doing wrong here?

Thanks in advance for your time and efforts
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import com.example.model.*;


you are importing a package that is not usefull for you and not exist please delete this line form code
for simple servlet example see this webpage
 
thirun pavan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your help and time...

How I can remove this line if I am declaring and using BeerExpert inside the code?!

Please check the line



If I removed the import line, I won't be able to declare and use the BeerExpert class

 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using ./ in your classpath? Does that lead to a real directory?
 
thirun pavan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Why are you using ./ in your classpath? Does that lead to a real directory?


I didn't, there is a space between the dot and the slash so it is;
javac -classpath /usr/share/tomcat6/lib/servlet-api.jar:classes:. /var/lib/......
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I can see the space now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!