• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet wont compile  RSS feed

 
Ray mann
Ranch Hand
Posts: 48
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I'm doing a course on java but cant seem to get my servlet to compile i keep getting this error im seriously stressed out iv missed my dead line and googled my mind off trying to but cant seem to fix it can some one please help me!!

errors:

C:\Users\Reign\Desktop\WebStocks.java:20: package javax.servlet does not exist
import javax.servlet.*;
^
C:\Users\Reign\Desktop\WebStocks.java:21: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\Users\Reign\Desktop\WebStocks.java:27: cannot find symbol
symbol: class HttpServlet
public class WebStocks extends HttpServlet


I am using textpad to compile and Tomcat as a webserver...

Any help will be great

thanks guys!!
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you setting the classpath for this program during compilation? It looks like you are not including the jar(s) that are necessary for this class to compile. See this FAQ for more details http://www.coderanch.com/how-to/java/CompilingServlets
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those classes don't come with the JRE (or the JDK), so you need to add them to your classpath during compilation. Look for a file called "servlet-api.jar" in the "lib" directory of your Tomcat installation.
 
Ray mann
Ranch Hand
Posts: 48
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jaikiran Pai thanks the solution was in your link, it was my environment that wasn't set up correctly! many thank, i was so stuck!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!