This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 64867 - Scanner Class not found in java.util
Summary: Scanner Class not found in java.util
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 5.x
Hardware: Macintosh Mac OS X
: P3 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-22 04:39 UTC by akamarcus
Modified: 2006-12-19 09:34 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Experimental Project for review (9.25 KB, application/x-compressed)
2005-09-23 16:48 UTC, akamarcus
Details
Revision of previous program - issues w/scanner class (9.02 KB, application/x-compressed)
2005-09-23 18:20 UTC, akamarcus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description akamarcus 2005-09-22 04:39:36 UTC
I was trying out the scanner class to experiment with it.  I entered \


import java.util.Scanner;

public class Echo
{
    public static void main (String[] args)
    {
        String message;
        Scanner scan = new Scanner (System.in);
        
        System.out.println ("Enter a line of text:");
        
        message = scan.nextLine();
        
        System.out.println ("You entered: \"" + message + "\"");
    }
}

and it gave me these compiler errors:

init:
deps-jar:
Compiling 1 source file to /Users/Mark/Documents/Mark/BYU Classes/Computer
Science 142/Experimental/build/classes
/Users/Mark/Documents/Mark/BYU Classes/Computer Science
142/Experimental/src/experimental/Echo.java:1: cannot resolve symbol
symbol  : class scanner 
location: package util
import java.util.scanner;
/Users/Mark/Documents/Mark/BYU Classes/Computer Science
142/Experimental/src/experimental/Echo.java:8: cannot resolve symbol
symbol  : class Scanner 
location: class Echo
        Scanner scan = new Scanner (System.in);
/Users/Mark/Documents/Mark/BYU Classes/Computer Science
142/Experimental/src/experimental/Echo.java:8: cannot resolve symbol
symbol  : class Scanner 
location: class Echo
        Scanner scan = new Scanner (System.in);
3 errors
BUILD FAILED (total time: 2 seconds)

Why can't I use the Scanner class?
Comment 1 Pavel Flaska 2005-09-22 08:47:33 UTC
It isn't a IDE bug, when your source contains errors.

Anyway, your source text and compiler error message doesn't correspond. Do you
have really 'import java.util.Scanner' with uppercase 'S' in your source?
Symbols are case-sensitive!
Comment 2 akamarcus 2005-09-23 16:17:38 UTC
I don't think the classes from JDK 1.5 are being used as a source for my
program.  I have installed it, but how do I import JDK 1.5 into NB?
Comment 3 Pavel Flaska 2005-09-23 16:26:14 UTC
Can you verify that you do not have your Echo.java src in default package and
also in experimental package? -- From compilation errors it seems that project
compile file from experimental/ package, but your source does not contain
package statement.

Can you zip your project and add it to this issue as attachement?
Comment 4 akamarcus 2005-09-23 16:48:04 UTC
Created attachment 25114 [details]
Experimental Project for review
Comment 5 Pavel Flaska 2005-09-23 17:02:18 UTC
Read the basics about java programming. It is *not* a netBeans bug. Your source
is uncompilable, because of errors. The same results you will get when you use
another IDE or commandline compiler!

Modify the echo class (Echo.java):

package experimental;

import java.util.Scanner;

with uppercase 'S'!

Main.java file is also incorrect.
Comment 6 akamarcus 2005-09-23 18:18:53 UTC
I'm sorry that I sent across a message that NetBeans was bugged, but I did not
intend for that to happen.  I just can't use the scanner class.  I fixed the
file "Echo.java" to your specifications, and do not believe there should be a
problem, but then again, I am just beginning to learn about Java programming. 
Do I need to  import JDK 1.5, because when I click on the "Libraries" drop down
box, all it shows is JDK 1.4.  By they way, when trying to resolve the issue, do
I leave it as "Resolved Invalid," even though I do not understand why it is
resolved, or do I re -open it?  Thank you.
Comment 7 akamarcus 2005-09-23 18:20:39 UTC
Created attachment 25121 [details]
Revision of previous program - issues w/scanner class
Comment 8 akamarcus 2005-09-23 18:21:13 UTC
re-opened
Comment 9 Jan Lahoda 2006-12-19 09:34:10 UTC
Hi,
    as I understand this issue, the problem is that JDK 5 is not used to build
and run your project, and so the j.u.Scanner (which is available since JDK 5) is
not found. I do not think this is a bug.

To assign JDK 5 to your project please either run the IDE on JDK 5 (which is
required for NB5.5 anyway), or create a new Java Platform in the Java Platform
Manager (Tools menu/Java Platform Manager) and select the newly created Java
platform in the Project Properties of your project.