| Author |
package problem
|
Veena Pointi
Ranch Hand
Joined: Jun 20, 2002
Posts: 442
|
|
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
|
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
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....
|
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
|
 |
Veena Pointi
Ranch Hand
Joined: Jun 20, 2002
Posts: 442
|
|
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
Joined: Jun 08, 2002
Posts: 3178
|
|
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
Joined: Jun 20, 2002
Posts: 442
|
|
|
Why my code is not working even when class file it is trying to find exist under same directory?
|
 |
Veena Pointi
Ranch Hand
Joined: Jun 20, 2002
Posts: 442
|
|
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
Joined: Jun 08, 2002
Posts: 3178
|
|
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
Joined: May 10, 2002
Posts: 341
|
|
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
Joined: Jul 11, 2001
Posts: 14112
|
|
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.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Veena Pointi
Ranch Hand
Joined: Jun 20, 2002
Posts: 442
|
|
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
Joined: Jun 08, 2002
Posts: 3178
|
|
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...
|
 |
 |
|
|
subject: package problem
|
|
|