Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Cannot find symbol errors

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where's the class User? The compiler is complaining that it doesn't understand what "User" means. Do you have a class named User?
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
User is the object name and class name is AnotherClass. I tried to work out the code from the link in Java ranch

https://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
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13075
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic