Results 1 to 7 of 7
  1. #1
    Alnegar is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default Cannot find symbol variable Keyboard...

    Hi, I'm new to Java, and I started out with my first class- I'm using Jcreator LE as an IDE and well, it's giving me an error every time I compile, saying 'Cannot find symbol variable Keyboard' and pointing towards the input statements. Please can someone tell me what I'm doing wrong and how to fix it? Here's my code;

    /**
    *My First Class
    */


    public class HelloWorld {

    public static void main (String args [] ) {

    String name;
    int age;

    System.out.print("Enter your name: ");
    name = Keyboard.readString(); //Pointing at this line...

    System.out.print("Enter your age: ");
    age = Keyboard.readInt(); //It's pointing me at this line too...

    System.out.println("My name is " + name +
    " and I am " + age + " years old.");
    }


    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What is Keyboard? Where and how have you used this before? Are you trying to use a Scanner object or is this in some 3rd party library that needs to be included in your program?

  3. #3
    Alnegar is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    well, want i want to do is input the input by the user by typing from the keyboard, as i was following an example in my notes...

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Alnegar View Post
    well, want i want to do is input the input by the user by typing from the keyboard, as i was following an example in my notes...
    How is the compiler supposed to know that? The word 'Keyboard' doesn't automagically ring a bell and make the compiler generate the correct code for you.

    kind regards,

    Jos

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Alnegar View Post
    well, want i want to do is input the input by the user by typing from the keyboard, as i was following an example in my notes...
    Either your teacher was using and importing a 3rd party library that has a Keyboard class with static methods, or he was using a Scanner class object. Only you and your notes know for sure.

  6. #6
    Alnegar is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    thanks all for your quick replies, i'll make sure i'll ask my teacher about it, i'll post you how it went.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Good luck. Note that if you will be using an object of the Scanner class, you'll need to change the method names to those used by Scanner objects such as nextInt() and nextLine().

Similar Threads

  1. Objects and Classes cannot find symbol variable.
    By argnsoccer in forum New To Java
    Replies: 22
    Last Post: 10-28-2010, 12:23 AM
  2. Java cannot find symbol- variable img
    By crutchfieldj in forum New To Java
    Replies: 3
    Last Post: 04-13-2010, 10:47 PM
  3. Cannot find symbol variable - Why? I can.. ^^
    By Mattedatten in forum New To Java
    Replies: 4
    Last Post: 03-08-2010, 07:07 PM
  4. Cannot find symbol variable pD! I cant fix it!!!
    By Addez in forum New To Java
    Replies: 2
    Last Post: 09-17-2009, 08:32 PM
  5. Cannot find symbol variable yourScore
    By Addez in forum New To Java
    Replies: 4
    Last Post: 08-17-2009, 10:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •