I guess you are using an IDE (like Netbeans or eclipse) which allows you to run the code even if certain classes are not compilable. During the application's runtime, if you access this class it would lead to this exception.

Solution :- Simply Clean Your Project and Build and Run Then Again.

Answer from Vikrant Kashyap on Stack Overflow
🌐
Reddit
reddit.com › r/learnprogramming › [java] import java.util.scanner not being recognized?
r/learnprogramming on Reddit: [Java] import java.util.Scanner not being recognized?
January 14, 2018 -

I'm trying to import the scanner class into my program (I'm using NetBeans) but when I type "import java.util.Scanner;" I get an error that says "cannot find symbol: class Scanner"

I thought maybe I typed it wrong so I even copy and pasted the line from code on a different working project and it's still saying that. Not sure where to go from here. Anyone know what could be causing this error?

Discussions

eclipse - how to import java.util.Scanner - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. I'm new to Java, and I'm stuck as to why I'm getting an error message whenever I import java.util.Scanner. More on stackoverflow.com
🌐 stackoverflow.com
netbeans - Java "import java.util.Scanner" not working - Stack Overflow
This is my first time coding, so I'm sorry if I caused you to facepalm. I wanted to use the Scanner class to read the user input. However, I get an error. I've stopped coding when I faced this pro... More on stackoverflow.com
🌐 stackoverflow.com
netbeans - Errors when trying to use import java.util.Scanner - Stack Overflow
I also get a not a statement error for the import line. Lastly I get illegal static declaration for the public static void line. Any help would be appreciated. Thanks! ... It seems you have an extra parenthesis at the end. Also you just need one class and one method to test your code like: import java.util.Scanner... More on stackoverflow.com
🌐 stackoverflow.com
"import java.util.Scanner;" isnt working, the message "Import "java.util.Scanner" could not be resolved" pops up, what am i doing wrong?
What IDE do you use? Notepad, eclipse, IntelliJ? Does a normal System.out.println(„Hello World“); in a main method work? Make sure you have a valid Java SDK installed, and that your project is configured to use the correct Java version. After you did that refresh the project, maybe restart your ide and check if it works :) More on reddit.com
🌐 r/javahelp
4
0
February 14, 2024
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 310948 › why-cant-i-import-java-util-scanner
Why cant i import java.util.scanner? [SOLVED] | DaniWeb
Common causes of "cannot import java.util.Scanner" in Eclipse Helios are build path and JRE configuration, not the IDE itself. Scanner was introduced in Java 5, so if your project or workspace is using an older or incomplete JRE (for example, ...
🌐
Coderanch
coderanch.com › t › 405551 › java › import-java-util-Scanner-issues
import java.util.Scanner issues (Beginning Java forum at Coderanch)
December 4, 2006 - Originally posted by Nathan Leniz: ... I'm not so sure it's an error in my code so much as perhaps an error in my system variables somewhere? But if that's the case, wouldn't the commands javac and java also not be working? ... Scanner was introduced with Java 1.5, so my guess is that your system PATH is pointing to a prior version (so the commands work, but not with new features).
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Java-Scanner-import
Java Scanner import
However, to use any classes in packages other than java.lang in your code, an import is required. The Scanner class is found in the java.util package, not java.lang.
🌐
Stack Overflow
stackoverflow.com › questions › 68057280 › how-to-import-java-util-scanner
eclipse - how to import java.util.Scanner - Stack Overflow
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("What is your name? "); String name = scanner.nextLine(); System.out.println("Hello "+name); } } On Line 1, I'm getting an error message saying "The type java.util.Iterator cannot be resolved.
Find elsewhere
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360009910759-Scanner-Java-Import-Non-Existence-Error
Scanner Java Import Non-Existence Error – IDEs Support (IntelliJ Platform) | JetBrains
November 18, 2020 - I wanted to make a user input Java project, so I typed in import java.util.Scanner; and then red lines appeared under it meaning that there was an error. So, I just ran the code to see if it was just a glitch, and then it said an error message. Can you help? B.T.W. here's the error message Error: Could not find or load main class com.company.Main Caused by: java.lang.ClassNotFoundException: com.company.Main
Top answer
1 of 3
2
What IDE do you use? Notepad, eclipse, IntelliJ? Does a normal System.out.println(„Hello World“); in a main method work? Make sure you have a valid Java SDK installed, and that your project is configured to use the correct Java version. After you did that refresh the project, maybe restart your ide and check if it works :)
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Stack Overflow
stackoverflow.com › questions › 72453008 › how-can-i-import-java-util-scanner-into-eclipse
How Can I Import java.util.Scanner into Eclipse? - Stack Overflow
Thank you 2022-05-31T19:26:18.27Z+00:00 ... Make sure you are typing in a class, when you create a new project in Eclipse it's created a module-info.java. To confirm right button in your src -> New -> Class.
🌐
Tek-Tips
tek-tips.com › home › forums › software › programmers › languages › java
The import java.util.scanner cannot be resolved error | Tek-Tips
May 16, 2012 - import java.util.scanner is invalid, because Scanner must be written with a capital "S" import java.util.Scanner is value
🌐
Reddit
reddit.com › r/javahelp › my until.java.scanner; doesn't work
r/javahelp on Reddit: my until.java.Scanner; doesn't work
August 30, 2022 - This is merely a warning that your IDE (Likely Eclipse) is giving you. It justs means you have added the import, but no one in your code is currently using the Scanner. If you write code to use the Scanner that warning will disappear.
🌐
GitHub
github.com › TheAlgorithms › Java › issues › 3808
The import java.util.Scanner is never used · Issue #3808 · TheAlgorithms/Java
January 9, 2023 - the above method was imported but never used. this can create errors in the code and it is reflected in the code editor(VS Code) once the PowerSum.java file is opened, the error message pops out
Author   TheAlgorithms
🌐
Reddit
reddit.com › r/javahelp › java util scanner not working
r/javahelp on Reddit: java util scanner not working
April 29, 2023 -

I am new to coding and have been following bro codes java coding series and the command doesn't work i tried adding it in myself but eclipse just doesn't care if i type it in and run the command it says error occurred during initialization of boot layer java.lang.module.findexception: module format not recognized and shows a path to my project files to one of the scanner libraries i manually putted in what do i do?

Top answer
1 of 4
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2 of 4
1
It seems that you are having problems with java.util.Scanner The wiki here has a page The Scanner class and its caveats that explains common problems with the Scanner class and how to avoid them. Maybe this can solve your problems. Please do not reply because I am just a bot, trying to be helpful. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Reddit
reddit.com › r/intellijidea › can't import java.util.scanner, even though have downloaded new jdk
r/IntelliJIDEA on Reddit: Can't import java.util.scanner, even though have downloaded new JDK
November 12, 2019 -

The problem is basically stated in the title. I've tried everything I could think of and what I have found in Google but nothing could resolve my problem. I'm currently running Java 11.02 on IntelliJ community edition (but have also tried with 11, no success though). The "java.util.scanner" isn't even underlined with a wavy red, but instead the word "scanner" is shown in red, the title is underlined though.

Does anyone know what I could try?