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 โ€บ 68057280 โ€บ how-to-import-java-util-scanner
eclipse - how to import java.util.Scanner - Stack Overflow
"); 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. It is indirectly referenced from required .class files". When I run it, the console says, "Exception in thread "main" java.lang.Error: Unresolved compilation problem: ... I'm using the Eclipse IDE.
Discussions

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
Java scanner not working on eclipse - Stack Overflow
The program compiles and runs, but it is not allowing me to input any value. The program just ends without letting me input anything. Why? package prac; import java.util.Scanner; public clas... 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?) ... Save this answer. ... Show activity on this post. I guess you are using an IDE (like Netbeans or eclipse... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Java "import.java.util.Scanner" Error on Eclipse IDE - Stack Overflow
I'm getting this syntax error here when I'm trying to use "import" keyword. My Eclipse showing "import java.util.Scanner;" as warning and when I'm trying to run I'm getting some weird output. 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".
๐ŸŒ
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.
๐ŸŒ
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.
Published: February 12, 2026
๐ŸŒ
Steemit
steemit.com โ€บ utopian-io โ€บ @aromatheraphy โ€บ how-to-use-scanner-class-in-java-with-eclipse-ide-explanation-with-example-miles-per-gallon-calculation
How to Use Scanner Class in Java with Eclipse IDE: Explanation with Example (Miles Per Gallon Calculation) โ€” Steemit
January 10, 2018 - To conculude, we can summuraze the scanner class in the following three steps; ... Step 3: Read your input Note: Use nextInt for integer inputs, Use nextDouble for double inputs ... If you want to try this example in your computer, you can find the text version of the code: import java.util.Scan...
Find elsewhere
๐ŸŒ
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
๐ŸŒ
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 โ€บ cameron mckenzie
How to import the Java Scanner - YouTube
If you are doing user input in your Java apps, you'll likely be using the Java Scanner. If that's the case, a Java Scanner import will be required.In this si...
Published: August 7, 2022
Views: 9K
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(...)

๐ŸŒ
YouTube
youtube.com โ€บ logic lambda
Getting User Input with the Java Scanner Class - YouTube
0:14 - Instantiating a Scanner Object0:35 - Checking errors in Eclipse0:59 - Importing the scanner class1:18 - Checking warnings in Eclipse1:25 - Reading an ...
Published: January 29, 2023
Views: 2K
๐ŸŒ
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.
๐ŸŒ
YouTube
youtube.com โ€บ watch
Scanner Class Part 1: import and syntax (Java) - YouTube
This video looks at how to import the Java Scanner Class and how to construct an object of the Scanner Class.
Published: September 5, 2013
๐ŸŒ
YouTube
youtube.com โ€บ watch
Importing and Using the Scanner Class - Java (INF-304) tutorial - YouTube
In this video from LearnKey's Java (INF-304) course, expert Jason Manibog demonstrates how to use Java's built-in Scanner Class to capture user input.
Published: April 8, 2021
๐ŸŒ
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