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

Java problem

  • 03-04-2009 5:56pm
    #1
    Registered Users, Registered Users 2 Posts: 1,148 ✭✭✭


    I wrote a programme in college recently and it compiled and ran fine. I then re-wrote the programme the exact same on my laptop in gedit and it wont compile.
    The error I get is:

    Words.java:15: cannot find symbol
    symbol : method endOfFile()
    location: class Console
    while(!Console.endOfFile())
    ^
    1 error

    Just wondering why it worked in college and won't work on my laptop?


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    punk_one82 wrote: »
    while(!Console.endOfFile())
    ^

    Console is the class. I suspect you called your object console.

    Change the C to c.

    If that is not it then check to see you have the right Console class in your imports, otherwise endOfFile() is wrong.

    Standard java coding convention is the classes start uppercase and variables start lowercase.


  • Registered Users, Registered Users 2 Posts: 1,148 ✭✭✭punk_one82


    I'm pretty sure that Console is supposed to use an uppercase C. Could it be that the console class in college is one that's exclusively used in college? I know they had their own graphics package.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    the error is that you don't have the method endOfFile() on the Object. As your starting with a capital it seems to suggest it is a static method.

    But endOfFile would suggest that you had to create an object using Console class so it might be that.

    For example:

    Console console = new Console();
    while (!console.endOfFile()) { ... etc.


  • Registered Users, Registered Users 2 Posts: 1,148 ✭✭✭punk_one82


    I sort of get what you're saying(I'm only a beginner.Still in first year), but what I'm really wondering is why did the exact same piece of code work in college? Sorry if I'm frustrating you, but like I said, I'm a beginner. :)


  • Registered Users, Registered Users 2 Posts: 18,272 ✭✭✭✭Atomic Pineapple


    Are you using textpad?

    I presume you import the Console class and it exists as part of the java package in the college but it doesn't on your own computer.

    You haven't actually created the Console class yourself?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 5,618 ✭✭✭Civilian_Target


    Another possibility:
    There is a java.lang.Console class that is a default import, afaik this does not have an endOfLine method.
    I suspect your code is attempting to access a different Console.class that should be in the same package, and is in your classpath in college. At home, it's not on your class path, and Java thinks it's using java.lang.Console, which does not have an endOfFile() method.

    Thus, you don't get the usual classpath error, instead it tries (and fails) to run.


  • Registered Users, Registered Users 2 Posts: 4,287 ✭✭✭NotMe


    Are you in DCU? :p You probably need this:

    http://www.computing.dcu.ie/~mmelia/resources/Console.java


  • Registered Users, Registered Users 2 Posts: 1,148 ✭✭✭punk_one82


    I am in DCU. :).Do I just save that in the same directory as my other work in java?


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    punk_one82 wrote: »
    I am in DCU. :).Do I just save that in the same directory as my other work in java?
    have it in the same directory as the current file you're trying to compile.

    i'm not trying to be smart here but i really don't think first years should be thought an object oriented language, it took me the guts of a year to get the swing of an OO with a year of proceedural programming under my belt, it is way too many concepts that you need to understand that really cloud over the VERY basics.

    don't let this put you off though, OO is pretty much where it is at :)


  • Registered Users, Registered Users 2 Posts: 1,148 ✭✭✭punk_one82


    It doesn't put me off at all. I love what we've done in java so far, although we obviously haven't touched on anything that in depth. Thanks for the help anyway.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    did it work?


  • Registered Users, Registered Users 2 Posts: 1,148 ✭✭✭punk_one82


    It compiles now, but I'm having more trouble with it. I'm sure I'll get it sorted.


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    good good, have an attempt at fixing it, and if not come back here and we'll only be too happy to help. :)


Advertisement