Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with Class

 
Beth Laguardia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And which line does it indicate?

I ran the same code and worked perfectly for me.
 
Beth Laguardia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your RollTheDice class need to be public.

public class RollTheDice
 
Ritvick Nigam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also to add you can compile them seperateky by keeping both the files in the same package.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic