wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem compiling a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem compiling a servlet" Watch "Problem compiling a servlet" New topic
Author

Problem compiling a servlet

Paulo Crestani
Greenhorn

Joined: Nov 06, 2007
Posts: 19
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

Joined: Jul 02, 2001
Posts: 697
For names with blanks (like "Program Files"), replace the 7th-Nth characters with ~1 ("Progra~1").

Hope this helps.


SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Compiling Servlets


[My Blog]
All roads lead to JavaRanch
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

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!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Paulo Crestani
Greenhorn

Joined: Nov 06, 2007
Posts: 19
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
 
subject: Problem compiling a servlet