This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help with Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with Class" Watch "Help with Class" New topic
Author

Help with Class

Beth Laguardia
Ranch Hand

Joined: Jun 01, 2008
Posts: 34
I know that my code is right but it still keeps giving me an error message "cannot find symbol".

Please help!



Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
And which line does it indicate?

I ran the same code and worked perfectly for me.
Beth Laguardia
Ranch Hand

Joined: Jun 01, 2008
Posts: 34
I am running it at the command prompt. It says

TestRollDice.java:7: cannot find symbol
symbol: class RollTheDice
location: class TestRollDice
RollTheDice newRoll = new RollTheDice();
^

TestRollDice.java:7: cannot find symbol
symbol: class RollTheDice
location: class TestRollDice
RollTheDice newRoll = new RollTheDice();
^
2 errors

Hmm.. I wonder what's wrong.
[ June 12, 2008: Message edited by: Beth Laguardia ]
Rodrigo Lopes
Ranch Hand

Joined: Feb 29, 2008
Posts: 119
your RollTheDice class need to be public.

public class RollTheDice
Ritvick Nigam
Greenhorn

Joined: Jun 06, 2008
Posts: 7
If you dont want to make your class RollTheDice as public then keep it in the same file as TestRollDice and compile it as TestRollDice.java
Ritvick Nigam
Greenhorn

Joined: Jun 06, 2008
Posts: 7
Also to add you can compile them seperateky by keeping both the files in the same package.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Continue to Rodrigo...
and the file containing that class(RollTheDice) need to be in the same package where 'TestRollDice' is.Otherwise you need to make the method (run) public.

There are couple of ways to make it run.

1) Put both the class in the same *.java file and you don't need to make any damn change.

2) Make two java files for both the class and put them in same package.
3) or put them in different package.

In 2 and 3 option you need to take care about the visibility of method and class.
Beth Laguardia
Ranch Hand

Joined: Jun 01, 2008
Posts: 34
Hello Evryone,

Thank you so much for the reply. I solved the problem by saving it to my USB/Memory stick. I cannot undertand why it does not run when my files is in laptop documents. Maybe because I am running vista?

And also I am not into package yet so I do not know what it means yet. I m really a beginner beginner.

Thank you for taking time to reply.

Thank you.
[ June 12, 2008: Message edited by: Beth Laguardia ]
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
I solved the problem by saving it to my USB/Memory stick.

How can that solve the problem?
Maybe because I am running vista?

Windows isn't that BAD.Please.
I am not into package yet so I do not know what it means yet

Please refer Java_package.
Beth Laguardia
Ranch Hand

Joined: Jun 01, 2008
Posts: 34
Originally posted by Vishal Pandya:

Please refer Java_package.


Thanks..

I do not know how it solved the problem but it did. Saving it to the documents does not run it but once i save it to the usb then run it to the usb it works perfectly.
[ June 13, 2008: Message edited by: Beth Laguardia ]
 
GeeCON Prague 2014
 
subject: Help with Class