Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2008
    Posts
    5
    Rep Power
    0

    Default java.util.Scanner not recognised

    Hi. I am writing a parser for a constructor that takes a String parameter and want to use a scanner class. I have confirmed I am using 1.5.0 (see output from command line below) and have imported java.util.* however when I compile I get the following errors

    Java Code:
    $ javac *.java
    2. ERROR in Argument.java (at line 46)
    	Scanner scan=new Scanner();
    	^^^^^^^
    Scanner cannot be resolved to a type
    ----------
    3. ERROR in Argument.java (at line 46)
    	Scanner scan=new Scanner();
    	                 ^^^^^^^
    Scanner cannot be resolved to a type
    ----------
    2 problems (2 errors)
    Can anyone help me to fix this problem?

    Thanks :)

    java -version output:
    Java Code:
    $ java -version
    java version "1.5.0"
    gij (GNU libgcj) version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)
    (PS I hope I posted this in the right place, it's my first time here)

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

    Default

    Are you importing the Scanner class properly with
    Java Code:
    import java.util.Scanner;
    ?

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    $ javac *.java
    2. ERROR in Argument.java (at line 46)
    Scanner scan=new Scanner();
    ^^^^^^^
    Scanner cannot be resolved to a type
    ----------
    3. ERROR in Argument.java (at line 46)
    Scanner scan=new Scanner();
    ^^^^^^^
    Scanner cannot be resolved to a type
    ----------
    2 problems (2 errors)
    all Scanner constructors have parameters....
    freedom exists in the world of ideas

  5. #5
    Join Date
    Jun 2008
    Posts
    5
    Rep Power
    0

    Default

    Quote Originally Posted by sukatoa View Post
    all Scanner constructors have parameters....
    I feel like such an idiot.

    Thanks though - that sorted me out :)

Similar Threads

  1. java.util
    By Java Tutorial in forum Java Tutorial
    Replies: 1
    Last Post: 02-07-2008, 02:46 PM
  2. Replies: 0
    Last Post: 11-20-2007, 05:59 PM
  3. Using ava.util.Scanner
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-20-2007, 05:47 PM
  4. Using java.util.Formatter
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-16-2007, 03:29 PM
  5. The import java.util.Scanner cannot be resolved
    By Heather in forum Advanced Java
    Replies: 1
    Last Post: 07-08-2007, 02:05 AM

Posting Permissions

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