• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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.
 
I've never won anything before. Not even a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic