I have been having a real problem with getting code to compile from the Head First
Servlets book. I am able to get the servlets themselves to compile as the when I compile by setting the classpath a follows:
C:\LearningProjects\beerV1\src\com\example\web>javac -classpath %CATALINA_HOME%\common\lib\servlet-api.jar BeerSelect.java
Using the -d flag, I also got the BeerSelect class to go to the right place, c:\LearningProjects\beerV1\classes\com\example\web.
The problem I am having is in
testing the BeerSelect class. In case you are not familiar with the stellar Head First series and its teaching code (do I get something for that flattery), it follows:
This class clearly does not require any servlet api functionality so compiling it was pretty straight forward. I compiled it with the -d flag and put the class file in the directory listed above (except in the model rather than the web node). In keeping with the iterative approach, I built a test class. It looks like this:
When I compile, I get the BeerExpert not found exception. How can this be? They are both in the same package. In any event, I have tried any number of incantations to overcome this problem. I want to solve my regular classpath problems once and for all. I suspect that this is just one of those. Here is the directory structure that I am using.
c:\LearningProjects\beerV1\src\com\example\model (javac from here)
c:\LearningProjects\beerV1\classes\com\example\model (put classes here and look for BeerExpert.class here).
Can you just walk me through this so that I can get it to compile and hopefully after doing that I will finally get it. I have gone through many web pages and books trying to figure this out. I think that I am doing what I am supposed to but my results are not good so I know I am doing something wrong.
Thanks,
Tom