... it works just fine, producing the .class file in correct package structure under "classes" folder.
BeerSelect class is a servlet. it has-a BeerExpert. BeerExpert is a "model" class, as in MVC pattern "model". it returns me an arraylist,nothing special. when i compile the BeerSelect the following is the output...
c:\practice\projects\BeerV1>javac -cp "%CATALINA_HOME%\lib\servlet-api.jar" -d c lasses src\com\example\web\BeerSelect.java src\com\example\web\BeerSelect.java:19: cannot find symbol symbol : class BeerExpert location: class BeerSelect BeerExpert be=new BeerExpert(); ^ src\com\example\web\BeerSelect.java:19: cannot find symbol symbol : class BeerExpert location: class BeerSelect BeerExpert be=new BeerExpert(); ^ 2 errors
then i think, ok, its not able to locate the BeerExpert class, so let me specify classes folder in -classpath option and i do this
c:\practice\projects\BeerV1>javac -cp "%CATALINA_HOME%\lib\servlet-api.jar":clas ses -d classes src\com\example\web\BeerSelect.java src\com\example\web\BeerSelect.java:4: package javax.servlet does not exist import javax.servlet.*; ^ src\com\example\web\BeerSelect.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*; ^ src\com\example\web\BeerSelect.java:10: cannot find symbol symbol: class HttpServlet public class BeerSelect extends HttpServlet{ ^ src\com\example\web\BeerSelect.java:11: cannot find symbol symbol : class HttpServletRequest location: class BeerSelect public void doPost(HttpServletRequest request,HttpServletResponse ^ src\com\example\web\BeerSelect.java:11: cannot find symbol symbol : class HttpServletResponse location: class BeerSelect public void doPost(HttpServletRequest request,HttpServletResponse ^ src\com\example\web\BeerSelect.java:19: cannot find symbol symbol : class BeerExpert location: class BeerSelect BeerExpert be=new BeerExpert(); ^ src\com\example\web\BeerSelect.java:19: cannot find symbol symbol : class BeerExpert location: class BeerSelect BeerExpert be=new BeerExpert(); ^ 7 errors
c:\practice\projects\BeerV1>
-------------- so now it cannot import any of the servlet classes as well. WHAT AM I DOING WRONG???
SCJP 5.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12269
1
posted
0
Classpaths for compiling servlets can get pretty complicated - and will get worse as you add more libraries.
Thats why I use the ANT utility and define classpaths in build.xml. Yes ANT has a steep learning curve but you will be glad you put in the effort.
Thanks for the suggestion, but technicaly, what did i do wrong in the way i called javac ??
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35250
7
posted
0
"%CATALINA_HOME%\lib\servlet-api.jar":classes
I haven't used Windows in a long time, but I think there are two issues here. One is that you can't enclose just part of a classpath in double quotes, it has to be the full path, like
"%CATALINA_HOME%\lib\servlet-api.jar:classes"
The other is that the colon separates classpath entries on Unix operating systems only; Windows uses the semi-colon, so try
"%CATALINA_HOME%\lib\servlet-api.jar;classes"
You can omit the double quotes, since there is no space character in the path.