I get the following error while trying to compile the servlet SeatPlanRequestServlet.java:
C:\TechMSeatPlan\WEB-INF\classes\seatplanner\controller>javac SeatPlanRequestSer vlet.java SeatPlanRequestServlet.java:10: package seatplanner.model does not exist import seatplanner.model.DataManager; ^ SeatPlanRequestServlet.java:25: cannot find symbol symbol : class DataManager location: class seatplanner.controller.SeatPlanRequestServlet DataManager dataManager = new DataManager(); ^ SeatPlanRequestServlet.java:25: cannot find symbol symbol : class DataManager location: class seatplanner.controller.SeatPlanRequestServlet DataManager dataManager = new DataManager();
The servlet references the DataManager.java class. I compiled the class through the command prompt and placed it in the right package path (classes>seatplanner>model). The SeatPlanRequestServlet is present in the package (classes>seatplanner>controller). The "classes" being referred to here is the classes folder in my web application.
My package statement is absolutely correct in both instances. All the paths are also correct, and yet I get this error while compiling the servlet.
What am I doing wrong here? Thanks for the help in advance. [ January 08, 2008: Message edited by: David O'Meara ]
Now, I have a question. What if I want to send this over for someone to deploy it on his/her own machine. How can I auto-set the classpaths on their machine? Will packaging the whole thing into a WAR file do the trick, or do I have to do something special?
There is a difference between compile-time and run-time classpaths. To send your web app to someone else, you would give them the context root and everything under it, ie the TechMSeatPlan directory.
At runtime, the web application ignores your system classpath and uses one determined by the container. As a basic description, a web app has access to the java libraries, the container's common libraries, the classes inthe WEB-INF/classes directory, and the libraries in the WEB-INF/lib directory.
To reiterate, to compile you need the classes dir on your local classpath, but this is taken care of for you at run time by the container.