Use the shortcut ctrl+shft+o in Eclipse. It automatically imports whatever classes needed and suggests you with possible imports if conflict occurs.

Answer from Vanaja Jayaraman on Stack Overflow
🌐
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
You can import or use directly in declaration like you're trying: import java.util.Scanner; public class yourClass{ Scanner scanner = new Scanner(); //or java.util.Scanner scanner = new Scanner(); }
🌐
Stack Overflow
stackoverflow.com › questions › 68057280 › how-to-import-java-util-scanner
eclipse - how to import java.util.Scanner - Stack Overflow
I'm new to Java, and I'm stuck as to why I'm getting an error message whenever I import java.util.Scanner. import java.util.Scanner; public class Main { public static void main(String[] args)...
Discussions

import java.util.Scanner issues in Eclipse - Stack Overflow
Technologies: MS Windows 10, Eclipse IDE (Oxygen? Main download from website) Java JDK 9.0.4 and Java Runtime Environment Along with the Oracle scan to confirm Java was set up, I was able to w... More on stackoverflow.com
🌐 stackoverflow.com
March 7, 2018
eclipse - the import java.util.scanner cannot be resolved - Stack Overflow
I am new to Java and programming and am following Derek Banas' tutorials on YouTube. This is my code thus far and I am getting an error saying "the import java.util.scanner cannot be resolved." I ... More on stackoverflow.com
🌐 stackoverflow.com
methods - Can't import java.util.Scanner - Stack Overflow
Does the import statement import java.util.Scanner give you an error? ... It might help to run a clean or clear all cached files manually - especially if your code compiles fine from command line (have you tried that?) ... I guess you are using an IDE (like Netbeans or eclipse) which allows ... More on stackoverflow.com
🌐 stackoverflow.com
Java "import.java.util.Scanner" Error on Eclipse IDE - Stack Overflow
A beginner Java programmer here using JDK 17 with latest Eclipse IDE. I'm getting this syntax error here when I'm trying to use "import" keyword. My Eclipse showing "import java.util. More on stackoverflow.com
🌐 stackoverflow.com
October 25, 2022
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 310948 › why-cant-i-import-java-util-scanner
Why cant i import java.util.scanner? [SOLVED] | DaniWeb
Let Eclipse add the import: type Scanner in your code, press Ctrl+1 and choose the import, or use Ctrl+Shift+O (Organize Imports). To verify the class exists in your JRE, use Ctrl+Shift+T and search for "Scanner".
🌐
YouTube
youtube.com › watch
Eclipse - Taking inputs Scanner class - YouTube
This video goes through how to take inputs in Java using the Scanner class
Published   September 15, 2012
🌐
YouTube
youtube.com › selected topics in it
Java 3: Using the scanner class in eclipse - YouTube
In this video, a demonstration of using the scanner class in eclipse is presented. In our UsingScanner class that is located inside the learning_java projec...
Published   March 15, 2020
Views   4K
Find elsewhere
🌐
Java Made Easy!
java-made-easy.com › java-scanner.html
Java Input Using Java Scanner
That is okay, because the code is actually missing something important. To fix this, right click on the main screen, go down to where it says Source, then select Organize Imports. This will import everything that your program is missing.
Top answer
1 of 1
2

About your "bug":
From experience i can tell you that eclipse has its special magical moments when something seems wrong to it and then out of a sudden it accepts it. This is because sometimes the background processes of eclipse are a little slow and it takes some time until it realizes what is actually happening. My recommendation here is for imports use Strg+O or autocompletion Strg+Space. This way you tell eclipse to search for what you need and choose from its offers or it just auto picks it if it sees only one possible fit. Then eclipse knows straight away what you are using and it doesn't have to wait for you to stop typing and run a background process to find out what you are trying to do.

About your programm:
For reading/writing from/to the console java uses InputStreams and OutputStreams. System.in points to the InputStream used to read from the console. System.out points to the OutputStream used to write on the console.

System.in alone would already be enough to read from the console. However a simple InputStream has very basic methods to read from the stream. It is more comfortable to use a wrapper class like a Scanner or a BufferedReader.

Scanner provides you with multiple methods to read from an InputStream, of which you use nextLine(). This method blocks the process until a linebreak (enter) was typed on the console. Then it returns everything that was typed as a String.

This String you can use now for multiple things. You can print them back on the console like you do at the moment with System.out.println(...) or you can use them for further operations. For that i would recommend you to save the returned value in a variable

Scanner scan = new Scanner(System.in);
String readLine = scan.nextLine();
scan.close();

With the value you then can do further operations like converting it to an Integer for example

Integer convertedNumber = Integer.parseInt(readLine);

Which you then could use to call your function isPrime(...)

🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Java-Scanner-import
Java Scanner import
In order to use the Java Scanner class in your code, you must either fully reference the java.util package when you call the Scanner, or you must add a Java Scanner import statement at the start of your class.
🌐
YouTube
youtube.com › watch
Import and Scanner in Java - YouTube
This video looks at the import statement in Java and shows how we can create a Scanner for reading input.Playlist - https://www.youtube.com/playlist?list=PLL...
Published   May 23, 2015
🌐
The Eclipse Foundation
eclipse.org › forums › index.php › t › 160778
Eclipse Community Forums: Newcomers » Problems with Java Scanner on Eclipse.. | The Eclipse Foundation
January 15, 2010 - The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects, including runtimes, tools and frameworks.
🌐
The Eclipse Foundation
eclipse.org › forums › index.php › t › 1081829
Eclipse Community Forums: Newcomers » Scanner/Eclipse | The Eclipse Foundation
October 7, 2016 - The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects, including runtimes, tools and frameworks.
🌐
MacRumors
forums.macrumors.com › software › developers › apple programming
Eclipse and OS X and import java.util.Scanner | MacRumors Forums
April 4, 2006 - I am using the import java.util.Scanner and i keep getting a message that says java.util.Scanner cannot be resolved. Please help me out so i dont have to spend much amount of time sitting in craptastic chairs in the labs. Thanks ... Is the Compiler compliance level in Eclipse set to 5.0?
🌐
Coderanch
coderanch.com › t › 405551 › java › import-java-util-Scanner-issues
import java.util.Scanner issues (Beginning Java forum at Coderanch)
December 4, 2006 - LoopLock.java:1: cannot resolve symbol symbol: class Scanner location: package util import java.util.Scanner; ^ And other various compile errors complaining about me trying to use Scanner. Here is a bit of the code from my java file. I'm not so sure it's an error in my code so much as perhaps ...
🌐
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.