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.
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?
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!
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?
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?
Created attachment 25114 [details] Experimental Project for review
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.
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.
Created attachment 25121 [details] Revision of previous program - issues w/scanner class
re-opened
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.