aspose file tools*
The moose likes Servlets and the fly likes Error : class not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error : class not found" Watch "Error : class not found" New topic
Author

Error : class not found

Aryan Jain
Greenhorn

Joined: Mar 01, 2012
Posts: 4
Hii...

I am getting class not found error while executing a program.
List of files
ClassMain.java

Manager.java,Clerk.java,SalesPerson.java,Employee.java these 4 classes extends CompanyEmployee.java

In ClassMain.java
i have created a subclass object using superclass reference like this
CompanyEmployee employeeTwo = new Manager();
employeeTwo.setAllowance(1000);

setAllowance is a method in Manager.java

while compiling i am getting
error cannot find symbol
employeeTwo.setAllowance(1000);

I have checked spelling of functions in both the files but their is no mistake.
So,please reply me.

Thanks in advance.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

Welcome to the Ranch!

Why do you think the problem is a class not found? From that error message, I see two possibilities:
1) employeeTwo does not exist (but that's not the case, you just declared it).
2) class CompanyEmployee does not have a method setAllowance that takes an int, long, float or double (and this must be the case).

Which class defined method setAllowance? If that's Manager, then you need to declare employeeTwo as Manager to be able to call that method.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Aryan Jain
Greenhorn

Joined: Mar 01, 2012
Posts: 4
Thanks for your quick response.

i have declared ProjectAllowance in Manager class which extends CompanyEmployee class
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

But method CompanyEmployee does not have that method, you so you can't use a variable of that type to call it.
Aryan Jain
Greenhorn

Joined: Mar 01, 2012
Posts: 4
Thank you....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error : class not found