Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in servlet complation

 
Himanshu Daurbi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using apache-tomcat server and I have already set classpath and Jdk path by environment variable. When I'm compiling my servlet as
C:>cd Users\him\applications\tomcat 5.5\webapps\myproject
c:>javac -classpath "Users\him\applications\tomcat 5.5\common\lib\servlet-api.jar";classes:. -d classes src\com\example\web\MyServlet.java

I am getting error like...

cannot find symbol
symbol : class HttpServlet


can anyone tell me what is the source of error.
thanks in advance........................................
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the relevant parts of your servlet? Like the import for HttpServlet?
 
Miku Ranjan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
you should use any IDE for development like eclipse or netbeans still if you want to compile manually you can put that lib path in environmental variable of path for Window.
 
Tim Moores
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miku Ranjan wrote:you can put that lib path in environmental variable of path for Window.

The correct place would be CLASSPATH, not PATH. I generally advise not to use CLASSPATH, it causes more problems than it fixes IMO.
 
Rajesh Grover
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii.... You might be forgot to import javax.servlet.http;
 
Dwarka Damodaran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hay Himanshu,

I am using apache-tomcat server and I have already set classpath and Jdk path by environment variable


If you have already set the classpath then why are you still refering it during compilation. Its better to remove it from environment variable or to remove it from your compilation command. (Here i am talking about the servlet-api.jar)

In general during these situations the best way to setup an environment is to use a .bat, .cmd or a .sh file and set everything in that rather than messing up with the environment variable. In that way you have better control over the current command prompt.

Hope this helps you.

Thanks and Regards,
Dwarka
 
Ajaybcamca Sharma
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey you should import javax.servlet first before compile the program
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic