File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem compiling a servlet

 
Paulo Crestani
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends,

I am very begginer with servlets and I am having trouble to compile my servlet class. For those who follow the Head First book, it is the example of chapter 3.

The problem is that the javac can not find the servlet classes like HttpServlet, HttpServletRequest and HttpServletResponse. In the book the authors use classpath to direct javac to the proper directory where to find the classes and in that example, the classes are under .../tomcat/commom/lib

I am working with Tomcat 6 and I did not find a dir .../tomcat/commom/lib. There is a ...\Tomcat 6.0\lib and I suppose it is this one, but it is under "Program Files" and javac is complaining about the blancs in the dir name. Is there a way to solve this?

Thanks,

Paulo Crestani.
 
Paul Michael
Ranch Hand
Posts: 697
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For names with blanks (like "Program Files"), replace the 7th-Nth characters with ~1 ("Progra~1").

Hope this helps.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiling Servlets
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Paulo.

Man, you need to add the servlet-api.jar file to your classpath.
Try adding the file path between double quotes in the command line. For example:

javac -cp "C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar" Bob.java

Give it a try. Hope this helps!
 
Paulo Crestani
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great thanks,

It works now! Guys I am sorry for posting such a naive question in this forum.

Now I noticed that there is another forum specially for Servlets on Java Ranch and I will stay on that one until I upgrade my level on Servlets so I can try SCWCD.

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic