views:

33

answers:

3

I'm studying via Head First's Servlets and JSPs, and doing the assignment on the third chapter.

On page 81, there's this javac call:

>     %javac -classpath /Users/bert/Applications2/tomcat/common/lib/  
    servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java  

I don't get what it's trying to do. The book says that everything on the path before common should be suited for my specific system, but I don't have a common/lib path (not that I know of). I'm working on ubuntu 9 and I have created the following directory structures for deployment and developing of the web app that the chapter talks about, neither of them has a common/lib/ path on them. Where can I find this on my machine?

+1  A: 

If you trace the rest of the path, you'll see that common/lib belongs to Tomcat, the engine on which you'll deploy and run your servlet when it's compiled and packaged.

I'm assuming that you've downloaded and installed Tomcat.

Since you said the book called for "common/lib", that tells me that the examples are based on Tomcat 5.5. Tomcat 6.x, the latest version, uses "lib" instead of "common/lib".

The point is that you need the servlet API JAR in order to compile successfully.

duffymo
+2  A: 

Which edition of the book are you using? The /common/lib is true for until with Tomcat 5.5 (Servlet 2.4). Since Tomcat 6.x (Servlet 2.5) and on the Servlet API libraries are available in /lib folder.

BalusC
I'm using the old version (for java 1.4) I figured something like this might be the issue. Thanks.
omgzor
+1  A: 

If you installed a packaged version of tomcat, it should be:

  • /usr/share/tomcat5.5/common/lib/servlet-api.jar for Tomcat 5.5
  • /usr/share/tomcat6/lib/servlet-api.jar for Tomcat 6

But my recommendation would be to get a binary distribution of Tomcat from the official website (get the version of the book if you want to stick to the book) and to uncompress it in your home folder (I put this kind of stuff in ~/opt)

Pascal Thivent
Yes, I did get the binary distribution. Thanks for the suggestion.
omgzor