andandandand
andandandand

Reputation: 22260

classpath question, head first servlets book

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?

Upvotes: 1

Views: 277

Answers (3)

Pascal Thivent
Pascal Thivent

Reputation: 570285

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)

Upvotes: 1

BalusC
BalusC

Reputation: 1108537

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.

Upvotes: 2

duffymo
duffymo

Reputation: 308733

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.

Upvotes: 1

Related Questions