• 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

Getting error while compiling Java File

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have following directory structure.


\WebContent\WEB-INF\classes\com\kogent\User.class
\WebContent\WEB-INF\src\com\kogent\User.java
\WebContent\WEB-INF\classes\com\kogent\Agent\GetUserAction.java

Below is the source for GetUserAction.java




When i tried to compile above java file i got following error.

Cannot find symbol
class User.


I know that above error is very simple and i tried all possible ways to eliminate it.
But could not succeed.

Could anyone please help me.

Thanks in Advance.
Jay.


 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The package declaration in your action source doesn't match where it is in your directory hierarchy.

Without knowing the classpath you're using to compile it's impossible to help anyway.

Why are you getting a request parameter from the HttpServletRequest? Is there a reason you're not using the built-in functionality of Struts 2?
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Thanks for reply.

This is just a example source given in Struts Black Book. Moreover i am getting parameter using HttpServletRequest because it shows how to use ServletRequestAware Interface using this example.

Below is the classpath:

%CLASSPATH%;D:\Eclipse_wrksp\Struts2Application\WebContent\WEB-INF\lib\struts2-core-2.0.11.1.jar;D:\Eclipse_wrksp\Struts2Application\WebContent\WEB-INF\lib\xwork-2.0.1.jar


Thanks.
Jay
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the package doesn't match. Are you compiling inside an IDE, or outside? What's in the %CLASSPATH% environment variable? With the incomplete information given I'm going to assume you're not including /WEB-INF/classes on the classpath, hence it can't find the class in question.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Thanks for reply.

GetUserAction is under com/kogent/action folder.
Moreover when i did echo %CLASSPATH% word %CLASSPATH% is being displayed in at the beginning of the CLASSPATH.
I am compiling code outside IDE as somehow (not sure why) IDE is not able to compile code automatically.
However i added /WEB-INF/classes in classpath and tried to compile it.
Now i am getting error related to HttpServletRequest.

Cannot Find Symbol
Symbol: class HttpServletRequest

But i have added servlet.jar in build path as well as in CLASSPATH. This jar is also present in the lib folder.

Not sure why is this coming.

Thanks.
Jay.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems like you're trying things at random.

> GetUserAction is under com/kogent/action folder.

That's not what your original post said--it'll take longer if the information provided isn't accurate.

> Moreover when i did echo %CLASSPATH% word %CLASSPATH% is being displayed in at the beginning of the CLASSPATH.

What OS are you using?

> But i have added servlet.jar in build path as well as in CLASSPATH. This jar is also present in the lib folder.

I find that unlikely, otherwise it wouldn't be showing up as not found. It should *not* be present in your WEB-INF/lib folder, if that's what you mean.

Give the *EXACT* command you're using to compile, the *EXACT* contents of the CLASSPATH variable (the setting of which, by the way, usually causes more trouble than is worth).
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Hey Just now i am able to compile GetUserAction.java class. Because servlet.jar files location was not proper in classpath.

Thanks for your suggestions and moreover i will consider all your advices and try to put accurate information from first post itself.

Thanks.
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic