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 Overflowimport java.util.Scanner issues in Eclipse - Stack Overflow
eclipse - the import java.util.scanner cannot be resolved - Stack Overflow
methods - Can't import java.util.Scanner - Stack Overflow
Java "import.java.util.Scanner" Error on Eclipse IDE - Stack Overflow
Videos
Scanner is a Java class. All classes in Java should start with a capital letter.
Change
java.util.scanner;
to
java.util.Scanner;
either import the class or import the whole package
Importing class
import java.util.Scanner;
2.Importing the whole package
`import java.util.*;`
First will import only the selected class and the second will import all the classes in the package.
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.
Make sure you have configured PATH, CLASSPATH and JAVA_HOME variable in system Environment variable.
1) It might refers older version of java then 1.5
or
2) May be not added PATH,CLASSPATH, JAVA_HOME variable there.
BTW Your code is works fine in my Eclipse.
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?
