This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Error : class not found Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply 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: 19216

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
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: 19216

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: 19216

You're welcome.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Error : class not found
 
Similar Threads
Help needed
java.rmi.RemoteException: Error processing ejb jar: Compilation failed
Installing cocoon1.8 on Orion application server
Kind attn. Mr Ajith
getting error while trying to approve data