Two Laptop Bag*
The moose likes Beginning Java and the fly likes Cannot find symbol errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot find symbol errors" Watch "Cannot find symbol errors" New topic
Author

Cannot find symbol errors

deepika deepi
Ranch Hand

Joined: Jan 23, 2012
Posts: 199
Hi all,
i am getting an error in this code posted. can any one help me ?


next file class name


Error:
[clrg@localhost check]$ javac Main.java
./AnotherClass.java:5: cannot find symbol
symbol : class User
location: class AnotherClass
public User updateUser(User u)
^
./AnotherClass.java:5: cannot find symbol
symbol : class User
location: class AnotherClass
public User updateUser(User u)
^
Main.java:8: cannot find symbol
symbol : class User
location: class Main
User myUser = new User();
^
Main.java:8: cannot find symbol
symbol : class User
location: class Main
User myUser = new User();
^
4 errors

What am i missing here and why i am getting this error ? Help me . why it is telling it cannot find the symbol?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Where's the class User? The compiler is complaining that it doesn't understand what "User" means. Do you have a class named User?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
deepika deepi
Ranch Hand

Joined: Jan 23, 2012
Posts: 199
User is the object name and class name is AnotherClass. I tried to work out the code from the link in Java ranch

http://www.coderanch.com/t/492694/java/java/Passing-variables-class-class-SOLVED#2690252

So please i am not sure about it. Please help me how to find the output
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

The code in that example wasn't complete, because it doesn't show the User class.

User is not the object name in your code. The name is myUser, which is of class User. Since User isn't a built in class, you have to provide it yourself. For that code to work, you need to have a User class with methods getName() and setName(String name).
raj warke
Greenhorn

Joined: Jan 22, 2001
Posts: 11
Follow the steps mentioned below -

STEP 1 :- Put below files in a folder 'xyz' -
1. Main.java
2. AnotherClass.java
3. User.java
STEP 2 :- Set path variable to -
";drivename:\full_directory_of_xyz_folder\xyz"

Now you can run the program.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11160
    
  16

raj warke wrote:
STEP 2 :- Set path variable to -
";drivename:\full_directory_of_xyz_folder\xyz"

Now you can run the program.

Why does he have to set the path variable? The OS can clearly already find the javac.exe program, and one would assume java.exe as well. Neither of those programs reside in the xyz directory (at least, I hope they don't).

I fail to see what this part has to do with anything.

FURTHER, if you set your PATH to ";drivename:\full_directory_of_xyz_folder\xyz", then you will probably break a LOT of other stuff, since the OS won't be able to run things that have been taken OUT of the PATH.

 
 
subject: Cannot find symbol errors
 
Similar Threads
outputting html content to the server
How a character save in 2 bytes in Java?
Passing variables from class to class (SOLVED)
can we create object of the interface and what is the base package of java ?
Intelligent Agents