• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem compiling a servlet

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For names with blanks (like "Program Files"), replace the 7th-Nth characters with ~1 ("Progra~1").

Hope this helps.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compiling Servlets
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic