CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2011
    Posts
    1

    Problems with Keyboard.readInt

    HI All,
    Just started some java in a local college and we seem to be using an older version of Jcreator along with jdk1.3. I have downloaded to most recent version of both to work on some code at home but seem to be having a problem getting Jcreator to recognise a Keyboard.readInt command.At college we have to point the Jcreator in a different path to a folder called KeySrc in JDk but this does not seem to exist in ther version I am using at home. Below is the code I am working on. using Jcreator 5 and jdk 1.6

    class ch1ex9{
    public static void main(String[]args){
    int j;
    System.out.print("Enter number:")
    Keyboard.readInt();
    System.out.println(j+"squared="+j*j)


    When running this i get the message "Cannot find symbol variable keyboard". Im pretty sure that the command has been replaced by something else more modern but any help with this would be greatly appreciated as I have an exam on this coming up soon. Thanks guys.

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: Problems with Keyboard.readInt

    problem getting Jcreator to recognise a Keyboard.readInt command
    Some terminology. I think what you mean by a command is called a method call.
    The expression: Keyboard.readInt()
    is a call to the static readInt() method for the class Keyboard. I say static because Keyboard is coded as a class name and not a varible name.

    To use that method call in your program you need access to the definition of the Keyboard class.
    That is often in a jar file. The jar file must be available to the javac command so it can find the definition. You need to find the jar file with the definition and add it to the javac classpath.
    Also if the Keyboard class is in a package you will want to import that package.

    been replaced by something else more modern
    Look at the Scanner class as a more modern class to use
    Norm

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured