not recognizing scanner

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rotaryfreak
    New Member
    • Oct 2008
    • 74

    not recognizing scanner

    Hi everyone,

    ive had this problem for a while and i cant seem to figure out why. I am using eclipse to create my java code. When import the Scanner class, create a new object and so on... eclipse compiles the code without problem, BUT, when i try to run the same code from command line, i get this error:

    Greeting.java:2 4: cannot resolve symbol
    symbol : class Scanner
    location : package util
    import java.util.Scann er;

    Greeting.java:8 9 cannot resolve symbol
    symbol : class Scanner
    location : class Greeting Scanner kb = new Scanner<System. in>;

    Greeting.java:8 9: cannot resolve symbol
    symbol : class Scanner
    location: class Greeting Scanner kb = new Scanner<System. in>;

    3 errors




    any ideas? FYI, im running java version 6.0, j2sdk1.4.2_13 and 1.4.2_18

    thx
  • Jibran
    New Member
    • Oct 2008
    • 30

    #2
    You need to update your JVM to version 1.5 for Scanner interface to work.

    Comment

    • rotaryfreak
      New Member
      • Oct 2008
      • 74

      #3
      i just did and it's still not working... i get the same error

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Your PATH variable is still pointing to the old 1.4 jdk. Update your PATH so that it points to at least jdk 1.5.

        Comment

        • rotaryfreak
          New Member
          • Oct 2008
          • 74

          #5
          this is what i have i my Path:

          User Variables for Path:
          C:\Program Files\Java\j2re 1.4.2_18\bin;
          C:\j2sdk1.4.2_1 8\bin;
          C:\j2sdk1.4.2_1 3\bin;
          C:\Program Files\Java\jdk1 .5.0_17\bin;
          C:\Program Files\Java\jdk1 .6.0\bin;
          C:\Program Files\Java\jdk1 .6.0_07\bin


          System Variables for Path:
          C:\Program Files\Java\j2re 1.4.2_18\bin\ja vac;
          C:\Program Files\Common Files\Adobe\AGL ;
          C:\Program Files\MATLAB\R2 007b\bin;
          C:\Program Files\MATLAB\R2 007b\bin\win32;
          C:\j2sdk1.4.2_1 3\bin;
          C:\Program Files\Java\jdk1 .5.0_17\bin;
          C:\Program Files\Java\jdk1 .6.0\bin;
          C:\Program Files\Java\jdk1 .6.0_07\bin


          still same error. I understand the scanner is not being recognized, but when i updated to 1.5.0_17, it should work and no luck. I mean, it still compiles in eclipse just not in command line. I actually had the same problem the first time i installed eclipse on this computer but i don't remember what i did to fix it... it was over 1 year ago :(

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Edit your path and remove all the references to jdk 1.4

            Comment

            • rotaryfreak
              New Member
              • Oct 2008
              • 74

              #7
              @r035198x thanks =D worked like a charm! really appreciate it!

              Comment

              Working...