Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Need Help! Java & TextPad

  • 02-02-2006 5:29pm
    #1
    Registered Users, Registered Users 2 Posts: 269 ✭✭


    I keep getting the same error message everytime i compile and try to rum a java program i write even though the same program worked when i ran it in college.

    I have installed the compiler J2SE Development Kit 5.0 Update 6
    I have installed TextPad
    And have my two classes saved in the folder where i save my Java programs

    program is as follows

    class ex1A{
    public static void main(String[]args){

    int f[]=new int[5]; //Array
    for(int j=0;j<f.length;j=j+1){ //For statement
    Screen.message("Enter a number into number"); //Writes message to screen
    f[j]=Keyboard.readInt(); //Assigns value from keyboard
    Screen.writeInt(f[3]); // Displays whats in variable
    }
    }
    }

    I keep getting the following error message

    C:\Documents and Settings\user\My Documents\JAVA Semester 2\ex1A.java:6: cannot find symbol
    symbol : variable Screen
    location: class ex1A
    Screen.message("Enter a number into number"); //Writes message to screen
    ^
    C:\Documents and Settings\user\My Documents\JAVA Semester 2\ex1A.java:7: cannot find symbol
    symbol : variable Keyboard
    location: class ex1A
    f[j]=Keyboard.readInt(); //Assigns value from keyboard
    ^
    C:\Documents and Settings\user\My Documents\JAVA Semester 2\ex1A.java:8: cannot find symbol
    symbol : variable Screen
    location: class ex1A
    Screen.writeInt(f[3]); // Displays whats in variable
    ^
    3 errors

    Tool completed with exit code 1

    Even though i have my Keyboard and screen class setup exactly like in college


Comments

  • Closed Accounts Posts: 888 ✭✭✭themole


    cyberwit wrote:



    Tool completed with exit code 1

    Even though i have my Keyboard and screen class setup exactly like in college

    but did you import them?


  • Registered Users, Registered Users 2 Posts: 269 ✭✭cyberwit


    No
    I got them from www.tonymullins.com


  • Registered Users, Registered Users 2 Posts: 4,188 ✭✭✭pH


    If you have the 3 files (Keyboard.java, Screen.java and ex1A.java) in the *same directory* and type:

    javac ex1A.java

    It will work fine


  • Registered Users, Registered Users 2 Posts: 269 ✭✭cyberwit


    Keyboard and Screen are classes


    I do not use this syntax -System.out.printIn("Hello World!")-; the above Keyboard and Screen allow me to use Screen.message("Hello");
    or
    Screen.writeInt(x); instead of System.out.printIn( )

    from Tony Mullins A first Course in Programming in Java


  • Registered Users, Registered Users 2 Posts: 4,188 ✭✭✭pH


    Still the same thing holds if they are in the same directory (the 2 class files and your java file) it compiles for me.

    However check that all files have exactly the right names - capitalisation is important.

    If that fails download the 2 java files from the website (Screen & Keyboard) and put them in the dir instead of the classes. The ones you have may have been compiled with a package identifier and won't work just put in the same dir.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    cyberwit wrote:
    No
    I got them from www.tonymullins.com

    Gah, there seems to be an epidemic of these sorts of classes in the educational sector. What is wrong with allowing the student to use the language's own I/O classes is beyond me.


  • Registered Users, Registered Users 2 Posts: 4,188 ✭✭✭pH


    rsynnott wrote:
    Gah, there seems to be an epidemic of these sorts of classes in the educational sector. What is wrong with allowing the student to use the language's own I/O classes is beyond me.
    I agree, a critique of the what the good Mr Mullins is teaching is in order!

    From Screen.java on the site
    public static void cursorpos(int x){
      int j;
      if(x>0)
        for(j=0;j<x;j++)
          System.out.print(" ");
      else
        ; // skip
      }
    

    How many things are wrong with those lines?
    :)


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    Yargh!!


Advertisement