PDA

Click to See Complete Forum and Search --> : problem compiling class


mbonfyre
Nov 27th, 2002, 12:38 PM
I've got a class (ArrayMenu) which uses class (Keyboard) to read which key is pressed to choose from a menu. Keyboard compiles but ArrayMenu has this error (and I don't understand what I've done wrong!) Any one help - please!

---------- javac ----------
ArrayMenu.java:33: cannot resolve symbol
symbol : variable Keyboard
location: class ArrayMenu
choice = Keyboard.readChar();
^
1 error
Output completed (1 sec consumed) - Normal Termination

If anyone wants to see the code for the classes I will post them

Kagey
Nov 27th, 2002, 06:41 PM
remove the package statement at the top of the keyboard.java file. then recompile keyboard.java, and place it in the same directory as ArrayMenu.java.

Good ol Java Software Solutions by Lewis and Loftus?

mbonfyre
Nov 28th, 2002, 01:15 AM
if I remove the package from Keyboard I get 6 errors and it will not compile. ArrayMenu will still not compile. They are both in the same directory

Kagey
Nov 28th, 2002, 04:54 PM
You must not have the one i was thinking of. sorry dude.

HairyDave
Nov 29th, 2002, 02:53 AM
Is readChar() a static method?

I ask because you've used Keyboard.readChar(). This means (I think) that it needs to be static. If its not then I think that the compiler tries to resolve Keyboard as a variable and not a class.

If its not static you need to declare a variable of typ Keyboard first.

If its not this problem then have you imported the class - it shouldn't be a problem cos they're in the same directory - but you never know. Are they in the same package?

I've asked a few questions as I'm not sure whats happening. If you need more help, give us a shout.

HD