This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package problem

 
Veena Pointi
Ranch Hand
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote following 2 servlet classes and saved them in directory C:\Documents and Settings\VEENA\JavaServlets ,where JavaServlets is package name.
class 1

class2

Class2 compiles fine ,but class1 is giving compiler error saying
HelloServlet3.java:17: cannot resolve symbol
symbol : variable ServletUtilities
location: class JavaServlets.HelloServlet3
out.println(ServletUtilities.headWithTitle(title)+

I have included C:\Documents and Settings\VEENA\JavaServlets and root directory ;. into the classpath.But still geting the compiler error.What might be the problem?
Thanks
Veena
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U have to find out where the compiled classes are placed after the compilation of ServletUtilities class and u have to set that folder to the classpath, not the folder that the source files are in...
If u use the standard location specified by the specification like under /WEB-INF/classes/JavaServlets, it will be easier to debug and maintain your web app... Otherwise, u'll have to find out everything manually...
Hope this helps....
 
Veena Pointi
Ranch Hand
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ko ko,
class files are placed in the same directory as source files.i.e C:\Documents and Settings\VEENA\JavaServlets
I checked it.Then logically it should not throw compiler error right?
Please reply
Thanks
Veena
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it will surely throw the compilation error, if ur HelloServlet3 cannot find the class that it has to use in its code... Why don't u try to place the class under the /WEB-INF/classes/JavaServlets and try to compile the HelloServlet3 again?
I think it is because ur HelloServlet3 class is trying to find that ServletUtilities class under that folder...
 
Veena Pointi
Ranch Hand
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why my code is not working even when class file it is trying to find exist under same directory?
 
Veena Pointi
Ranch Hand
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it
Was setting classpath wrongly.I changed classpath from C:\Documents and Settings\VEENA\JavaServlets to C:\Documents and Settings\VEENA
Now it is working
Veena
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veena, I'm curious to know what web container you are using... Seems like u are developing the servlets on ur own and they are not under the specified folder as in the specification?
or you just want to test whether they are compiled or not... If I am not wrong, u have to deploy them in the appropriate folders to be able to run them properly as a part of ur web app...
Just curious on ur implemention....
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the following...
In directory:
C:\Documents and Settings\VEENA>
and use javac compiles:
C:\Documents and Settings\VEENA>javac \JavaServlets\HelloServlet3.java
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Veena Point:
I got it
Was setting classpath wrongly.I changed classpath from C:\Documents and Settings\VEENA\JavaServlets to C:\Documents and Settings\VEENA
Now it is working

Yep, it is the root directory which needs to be in the classpath. Javac will automatically traverse the package structure from there.
 
Veena Pointi
Ranch Hand
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ko Ko Naing:
Veena, I'm curious to know what web container you are using... Seems like u are developing the servlets on ur own and they are not under the specified folder as in the specification?
or you just want to test whether they are compiled or not... If I am not wrong, u have to deploy them in the appropriate folders to be able to run them properly as a part of ur web app...
Just curious on ur implemention....

Ko Ko,
I didn't have problem with deploying servlets,I know how to run servlets,I had problems with simple java packages.BTW I am using Tomcat5.016 servlet container.And this is the directory I am putting class files into to make servlets with packages examples I mentioned earlier run.
C:\tomcat5.0\webapps\ROOT\WEB-INF\classes\JavaServlets
Thanks
Veena
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Veena Point:

Ko Ko,
I didn't have problem with deploying servlets,I know how to run servlets,I had problems with simple java packages.BTW I am using Tomcat5.016 servlet container.And this is the directory I am putting class files into to make servlets with packages examples I mentioned earlier run.
C:\tomcat5.0\webapps\ROOT\WEB-INF\classes\JavaServlets
Thanks
Veena

Veena, it's good that u know how to deploy... I'm just afraid that u developed the servlets outside and don't know how to deploy it in the real application...
And also if u have placed your classes in the folder that u specified above, u don't need to set the classpath for that... Coz it's automatically done by the web container...
Just my 2 cents...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic