• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HelloServlet can not compile

 
tehika danait
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear ranchers
I am just biggining the preparation for scwcd and when i try to compile the following code it gives compiler error; please help me:

this code is from the book:Java the complete reference 5th edition page 953 and the error says:

package javax.servlet does not exist
package javax.servlet.http does not exist
cannot find symbol
cannot find symbol class ServletRequest
cannot find symbol class ServletResponse
cannot find symbol class ServletException


 
Swastik Dey
Rancher
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
servlet specification is not a part of standard java. You need to set the classpath to servlet api library. Best thing is to use some ide(s) like netbeans,myeclipse etc.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote: Best thing is to use some ide(s) like netbeans,myeclipse etc.

No, it helps, but it's not the best thing to do. Because it means that you (I don't mean "you" of course) can't even compile a class file, so in my opinion, you are not qualified enough to pass SCWCD. Your suggestion about setting the servlet api library in the classpath is good. We have a FAQ about compiling servlets, here.
 
tehika danait
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
According to Swastik and Christophe, I set my CLASSPATH variable to: C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar
as the servlet-api is found at C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib in my computer.
Unfortunately it is not still compiling. the compiler which i am using is JCreator.
what else my be the problem or is there somethig wrong in setting my CLASSPATH?

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath has to be set in JCreator, but I don't know this editor, so I can't help you. Check your editor's documentation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic