I just got Head First Servlets & JSPs, but am stuck at the first real exercise. Specifically I can't seem to import the javax.servlet, javax.servletHTTP packages. I set the classpath to Library/tomcat/common/lib/servlets-api.jar and try to compile but it isn't finding the servlet packages for some reason.
I'm using the terminal to compile and have tried setting the classpath to everything(and in every way) I can think of. I see the package in my tomcat folder, I just can't seem to access it.
1.) setting the classpath at compile time with javac -classpath /Library/tomcat/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java (taken straight out of the book)
2.) setting the classpath as a shell variable with export CLASSPATH=/Library/tomcat/common/lib/servlet-api.jar
I also tried copying the jar file to where I think my Java Home directory is.
So far no luck. I understand classpath but have never really had to worry too much about setting it. Up until now everything I've done at home has been with the standard jdk and never had to set the classpath. And at work I use WSAD and never have to worry about setting it. Now I've got the Head First book and want to spend some time learning more about Servlets and JSPs at home on my iMac, but so far I've been stuck on this problem for a couple days now. I've searched the internet and tried everthing I've found, I've searched different forums (this is the only mac specific) with no luck. I do know something about Java (am a SCJP) and a little about J2ee, but right now this is making me feel like an idiot, because I can't figure it out!
Thanks for the input Bear. I agree it's got to be something simple I'm missing. I've read a little about Ant and will learn it as I go along, for now I wanted to start at the beginning (of the book) and go step by step, thus why I'm compiling from command line.
When I get home this afternoon I'm going to start over and see if I can get it to work. I'll post here any progress or break throughs I have.
Edit: It did indeed to be something obvious that I was missing. All along I though my classpath was starting at my user and looking in my Library/tomcat/... When it was actually starting at my hard drive, which makes sense but since when I log into the termial I am automatically starting in my users folder I just assumed that's where my classpath was starting to look. Dumb Mistake. The funny thing is I have tomcat installed in both Library's (unnecessarily) which led to all the confusion. The one in my root Library folder just didn't have the servlet-api.jar it had the servlet.jar. Anyway thanks for the help Bear at least you re-affirmed my own thought that I was missing something simple, leading me find my error. [ March 18, 2005: Message edited by: Wyatt Humphries ]