Scanner is a Java class. All classes in Java should start with a capital letter.

Change

java.util.scanner;

to

java.util.Scanner;
Answer from David.Jones on Stack Overflow
🌐
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.
Discussions

eclipse - how to import java.util.Scanner - Stack Overflow
You can tell eclipse about all of em and pick a JDK to use for each project and even each run/debug. The current most recent stable version should be fine. NOTE: This problem has nothing to do with Scanner specifically. It won't even find java.lang.String - it will fail the first time you use ... More on stackoverflow.com
🌐 stackoverflow.com
java.util.Scanner cannot be resolved - Stack Overflow
Any help would be appreciated, I have refreshed Eclipse and restarted it - I am still receiving this error. Note: When I change the import to import java.util.* I receive no further errors on the import but the Scanner instance still errors. Update: I took a print screen if it helps anyone. Resolved ... More on stackoverflow.com
🌐 stackoverflow.com
February 4, 2017
methods - Can't import java.util.Scanner - Stack Overflow
I have been trying to create program that lets a user input a number of eggs to buy and calculates the price. I have tried using the scanner method to input the integer, but I can't seem to import ... More on stackoverflow.com
🌐 stackoverflow.com
java - Scanner cannot be resolved to a type - Stack Overflow
I just installed Ubuntu 8.04 and Eclipse. I made a very simple Hello World program in order to ensure that everything is running smoothly. When I attempted to use the Scanner class for acquiring some More on stackoverflow.com
🌐 stackoverflow.com
🌐
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.
🌐
Stack Overflow
stackoverflow.com › questions › 42033544 › java-util-scanner-cannot-be-resolved
java.util.Scanner cannot be resolved - Stack Overflow
February 4, 2017 - Any help would be appreciated, I have refreshed Eclipse and restarted it - I am still receiving this error. Note: When I change the import to import java.util.* I receive no further errors on the import but the Scanner instance still errors. Update: I took a print screen if it helps anyone. Resolved because I updated my Java, I had to manually tell Eclipse my JDK path.
Find elsewhere
🌐
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.
🌐
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 - Sorry, I was a bit too fast it should read the line "import java.util.scanner" is invalid, because Scanner must be written with a capital "S" Valid is: import java.util.Scanner
🌐
Coderanch
coderanch.com › t › 668716 › java › error-scanner-resolved-type
error scanner cannot be resolved to a type (Beginning Java forum at Coderanch)
Tapas Chand wrote:The error is because Scanner class does not have a constructor taking PrintStream as argument. You should provide InputStream.
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
If it is showing an error when trying to import, the most likely culprit is that you are putting it in the wrong place. import java.util.Scanner; // It should be above the class public class ClassName{ }
🌐
Stack Overflow
stackoverflow.com › questions › 34268894 › xxx-cannot-be-resolved-string-scanner-etc-after-importing-files
eclipse - 'xxx' cannot be resolved (String, Scanner etc.) after importing files - Stack Overflow
package com.sarthak.main; import java.util.Scanner; public class Myfirstgame { public static void main(String[] args) { System.out.println("Welcome to Momo Land, a place full of horror and utter momoness "); System.out.println("Enter Your Name: "); Scanner input = new Scanner(System.in); String name=input.nextLine(); MyGame game=new MyGame(name); game.run(); } } Things like System.out.println , input game.run etc. can't be resolved for some reason. eclipse ·
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(...)

🌐
Team Treehouse
teamtreehouse.com › community › java-cannot-be-resolved-to-a-variable
Java - Cannot be resolved to a variable? (Example) | Treehouse Community
January 2, 2014 - I'm getting this weird error and eclipse is telling me my finalAmount variable can't be resolved. From looking at it I know it's outside of the scoop of the for statement and everytime I create a local variable and assign a value to it (it's zero) my program gets messed up. My question is, how would I declare the finalAmount variable locally? ... import java.util.Scanner; public class CompoundInterest { public static void main(String[] args){ double rate; double amount; double year; System.out.println("This program, with user input, computes interest.\n" + "It allows for multiple computations.
🌐
Tek-Tips
tek-tips.com › home › forums › software › programmers › languages › java
New to Java getting error: Scanner cannot be resolved or is not a type | Tek-Tips
February 18, 2006 - Code is the following: import java.util.*; public class FirstProject { public static void main(String[] args) { System.out.println("Hello out there."); System.out.println("I will add two numbers for you."); System.out.println("Enter two whole numbers on a line:"); int n1, n2; Scanner keyboard = new Scanner(System.in); n1 = keyboard.nextInt( ); n2 = keyboard.nextInt( ); System.out.println("The sum of those two numbers is"); System.out.println(n1 + n2); } } Error is: Scanner cannot be resolved or is not a type The import java.util is never used Today I went to the following link: https://sdlcweb2d.sun.com/ECom/EComActionServlet;jsessionid=C7F951B9667B8A7C63CF7BA88A714429 and downloaded jdk-1_5_0_06-windows-i586-p-iftw.exe I installed it but I am still getting the same error. I am using Eclipse.
🌐
Reddit
reddit.com › r/learnprogramming › [java] the import java.util.math cannot be resolved
r/learnprogramming on Reddit: [Java] The import java.util.Math cannot be resolved
February 13, 2014 -

I'm writing a program to calculate the wind chill based on a temperature and wind speed entered by the user. The formula to calculate wind chill is

Wind Chill = 35.74 + 0.6215T - 35.75V0.16 + 0.4275TV0.16

My current code is

import java.util.Scanner;
import java.util.Math;
public class WindChill {

public static void main(String[] args) {
	
	//Declare variables

	double windChill;
	double temperature;
	int    windSpeed;

//Ask the user for temperature and wind speed

System.out.print("Enter the temperature (Fahrenheit):  ");
	Scanner input = new Scanner (System.in);
	temperature = input.nextDouble();

System.out.print("Enter the wind speed(mph):  ");
	windSpeed = input.nextInt();

	
//Display the wind chill value

windChill = (35.74+(0.6215*temperature)) - (Math.pow(35.75*windSpeed,0.16)) + (Math.pow(0.4275*temperature*windSpeed,0.16));	
System.out.print("The wind chill index is " + windChill);
}

}

I get an error in the IDE on line 2 that says "the import java.util.Math could not be resolved". Also, when I try to run the program, I get the error message

"Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

at WindChill.main(WindChill.java:6)

I checked my installed JREs and I am using JRE7. Can anybody tell me what is wrong?

🌐
DaniWeb
daniweb.com › programming › software-development › threads › 249689 › cannot-be-resolved
java - cannot be resolved | DaniWeb
December 30, 2009 - In Eclipse, Ctrl+1 (Quick Fix) and Ctrl+Shift+O (Organize Imports) help catch these issues fast.