Click to See Complete Forum and Search --> : Cannot Resolve Symbol Help


1945fighter
March 22nd, 2008, 09:28 AM
Hi I am new at java and I am making a java program for employee. I get 63 errors on cannot resolve symbol. Please advice, this is urgent and I rally appreciate your help. I attach .java file.

Londbrok
March 22nd, 2008, 10:12 AM
Go through it and fix the typos on method calls, and and it is all dandy. You call Employee_read(...) which should start with lower case letters, for example. Outside of that, having a class Employee and a class employee is just silly. and I do suppose these dont actually reside in the same java file? Just just pasted them to the same file for the purposes of attaching just one file?

If they do, that wont work. You are only allowed to have one public class to one java file. But there if there is no mandatory reason why you have the employee class to begin with, removing that fixes things... just the class, not the contents.

1945fighter
March 22nd, 2008, 10:42 AM
Go through it and fix the typos on method calls, and and it is all dandy. You call Employee_read(...) which should start with lower case letters, for example. Outside of that, having a class Employee and a class employee is just silly. and I do suppose these dont actually reside in the same java file? Just just pasted them to the same file for the purposes of attaching just one file?

If they do, that wont work. You are only allowed to have one public class to one java file. But there if there is no mandatory reason why you have the employee class to begin with, removing that fixes things... just the class, not the contents.

Hi I appreciate your help but none of it seems working. I am new at this can you help me with the coding and attach it back. It's just my typing right? I have change the public class name and method to lower case. Thank you.

Londbrok
March 22nd, 2008, 10:53 AM
can you help me with the coding and attach it back.

You want me to fix the code for you? Sadly thats not how this works out. I fixed your earlier code, told you what was wrong with it. If you have trouble with it, post your error here, then we can have a look, how you can go about fixing it. But asking people to do it for you, is not the policy of this site.

So post the error. And be sure that you are running the exact same code that you have posted here, else we are all shooting blanks in the dark.

1945fighter
March 22nd, 2008, 10:57 AM
Right, sorry. But my second code is the exact same as previous with the changes that you told me too (I hope). And it still get the same errors.

Londbrok
March 22nd, 2008, 11:10 AM
yes... and post the errors so we can work them out.

1945fighter
March 22nd, 2008, 11:18 AM
It is cannot resolve symbol error. And I got 63 of them. I' m not quite sure what you mean by "post you error".

Londbrok
March 22nd, 2008, 11:31 AM
Erors produce an errorstack, that details where the error is, what is it, where the application was prior encountering the error... sort of a full backlog of what happened. Cannot find symbol -error means that something you are referencing simply does not exists. For example, you still have a typo in Employees constructor, which would result a Cannot find symbol error. Fix that.

I dont know what you code with, simple notepad, actual IDE or what. But least the code you have posted does not contain any imports. You do have required classes declared in the imports? If not you are bound to get gazillion of such errors.

Outside of that, if you have your two classes in separate java files, or remove the staff class declaration, your code works just fine.

1945fighter
March 22nd, 2008, 12:03 PM
I use jcreator n it showed 64 errors n then disappear and show me this:

--------------------Configuration: <Default>--------------------
java.lang.NoClassDefFoundError: worker
Exception in thread "main"
Process completed.

Londbrok
March 22nd, 2008, 12:11 PM
Name of the java.file MUST match the name of the public class declared in the file. You have file named worker.java and class declared as Employee.

Londbrok
March 22nd, 2008, 12:42 PM
I asked you this earlier, but just to make sure.

If this what you posted, is your actual java file, (as in not something you pasted together for the purposes of attaching it here) there are several things awry.

1) You have two public classes in the file. While Employee is not declated public, it is public by default. Also Staff is public. You cannot have this. It simply will not work. Either break them to separate classes (resulting separate files), or you can make one inner class of the other. Advice to take the first option.

2) Where are the imports? For the class to get to use all the things you use, the relevant classes need to be declared in the imports. Else it just wont work. Here is the import declarations that I have for testing the code.


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;


3) The name of the file must match the name of the public class declared. Which is why you cannot have more than one public class to a file. Could it be that you have at a stage just pasted new code or renamed the class by brure force? That would explain this odd incosistency. Always when renaming anything, be it a class, method or variable... use the renaming tools provided by the IDE. Usually they also apply the change where ever changed element is referenced.

1945fighter
March 22nd, 2008, 12:51 PM
Thx for your help. It works now. I rewrote the whole thing again though.