Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Package error while compiling servlet

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add "C:\TechMSeatPlan\WEB-INF\classes\" to classpath
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, that's needed as well? Fine. I'll try it out.

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?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need a classpath for deployment.
The container will look for the needed classes in the directories where they're expected to be.

So, yes, packaging the app in a war file will take care of it.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your replies and assistance.

It was stupid of me to ask this question. I just realized that after I posted it!
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sridhar Venkataraman:
Thank you for your replies and assistance.

It was stupid of me to ask this question. I just realized that after I posted it!



At times it happens . Don't worry, good people are here to remind of the forgotten things as well.
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sridhar Venkataraman:
Thank you for your replies and assistance.

It was stupid of me to ask this question. I just realized that after I posted it!


There is no such thing as a stupid question.
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sudhir nim:
Add "C:\TechMSeatPlan\WEB-INF\classes\" to classpath



I did this (added it under the classpath in the environment variables), and it still didn't work.

*sigh*

I echoed the classpath and found it to be set correctly. I use Windows Vista.

[ January 08, 2008: Message edited by: Sridhar Venkataraman ]
[ January 08, 2008: Message edited by: Sridhar Venkataraman ]
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This issue has also been resolved. I was trying to compile from the wrong folder .
 
reply
    Bookmark Topic Watch Topic
  • New Topic